Esempio n. 1
0
        public override void OnEnter()
        {
            if (!MaintainState)
            {
                DefaultFont = Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Default);
                GUI         = new DwarfGUI(Game, DefaultFont,
                                           Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Default),
                                           Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Small), Input);
                IsInitialized = true;
                Logo          = TextureManager.GetTexture(ContentPaths.Logos.gamelogo);

                ListSelect = new ListSelector(GUI, GUI.RootComponent)
                {
                    Label       = "- Main Menu -",
                    LocalBounds =
                        new Rectangle(Game.GraphicsDevice.Viewport.Width / 2 - 100, Game.GraphicsDevice.Viewport.Height / 2,
                                      150, 150)
                };
                DefaultItems();

                ListSelect.OnItemClicked += ItemClicked;
                Drawer = new Drawer2D(Game.Content, Game.GraphicsDevice);
                Input  = new InputManager();
            }

            base.OnEnter();
        }
Esempio n. 2
0
        void Initialize()
        {
            GUI = new DwarfGUI(Game, Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Default), Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Title), Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Small), Input)
            {
                DebugDraw = false
            };
            IsInitialized = true;
            Drawer        = new Drawer2D(Game.Content, Game.GraphicsDevice);
            MainWindow    = new Panel(GUI, GUI.RootComponent)
            {
                LocalBounds = new Rectangle(EdgePadding, EdgePadding, Game.GraphicsDevice.Viewport.Width - EdgePadding * 2, Game.GraphicsDevice.Viewport.Height - EdgePadding * 2)
            };
            Layout = new GridLayout(GUI, MainWindow, 11, 4);
            Label title = new Label(GUI, Layout, "You Lose!", GUI.TitleFont);

            Layout.SetComponentPosition(title, 0, 0, 4, 4);

            Label text = new Label(GUI, Layout,
                                   "The heady days of exploration for " + PlayState.Master.Faction.Economy.Company.Name +
                                   " are no more.\n Our stock is through the floor. Our investors have all jumped ship! \n We are going to have to sell the company. If only we had shipped more goods...",
                                   GUI.DefaultFont)
            {
                WordWrap = true
            };

            Layout.SetComponentPosition(text, 0, 4, 4, 4);

            Button okButton = new Button(GUI, Layout, "OK", GUI.DefaultFont, Button.ButtonMode.PushButton, null);

            okButton.OnClicked += okButton_OnClicked;
            Layout.SetComponentPosition(okButton, 2, 10, 2, 1);
            Layout.UpdateSizes();
        }
Esempio n. 3
0
        void Initialize()
        {
            Tabs       = new Dictionary <string, GUIComponent>();
            Icons      = TextureManager.GetTexture(ContentPaths.GUI.icons);
            TabButtons = new List <Button>();
            GUI        = new DwarfGUI(Game, Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Default), Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Title), Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Small), Input)
            {
                DebugDraw = false
            };
            IsInitialized = true;
            Drawer        = new Drawer2D(Game.Content, Game.GraphicsDevice);
            MainWindow    = new GUIComponent(GUI, GUI.RootComponent)
            {
                LocalBounds = new Rectangle(EdgePadding, EdgePadding, Game.GraphicsDevice.Viewport.Width - EdgePadding * 2, Game.GraphicsDevice.Viewport.Height - EdgePadding * 2)
            };
            Layout = new GridLayout(GUI, MainWindow, 11, 4);
            Layout.UpdateSizes();

            Button back = new Button(GUI, Layout, "Back", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.LeftArrow));

            Layout.SetComponentPosition(back, 0, 10, 1, 1);
            back.OnClicked += back_OnClicked;

            Panel tabPanel = new Panel(GUI, Layout);

            Layout.SetComponentPosition(tabPanel, 0, 0, 4, 1);

            GridLayout tabLayout = new GridLayout(GUI, tabPanel, 1, 10)
            {
                EdgePadding = 10
            };


            CreateTabButton(tabLayout, "Employees", "Hire and fire dwarves", 5, 0);
            EmployeeDisplay employeeDisplay = new EmployeeDisplay(GUI, Layout, PlayState.Master.Faction)
            {
                IsVisible = false
            };

            Tabs["Employees"] = employeeDisplay;

            CreateTabButton(tabLayout, "Assets", "Buy/Sell goods", 3, 1);
            GoodsPanel assetsPanel = new GoodsPanel(GUI, Layout, PlayState.Master.Faction)
            {
                IsVisible = false
            };

            Tabs["Assets"] = assetsPanel;


            CreateTabButton(tabLayout, "Capital", "Financial report", 2, 1);
            CapitalPanel capitalPanel = new CapitalPanel(GUI, Layout, PlayState.Master.Faction)
            {
                IsVisible = false
            };

            Tabs["Capital"] = capitalPanel;

            ButtonClicked(TabButtons[0]);
        }
Esempio n. 4
0
 public WaitState(DwarfGame game, string name, GameStateManager stateManager, Thread waitThread, DwarfGUI gui)
     : base(game, name, stateManager)
 {
     WaitThread = waitThread;
     GUI        = gui;
     OnFinished = () => { };
     Done       = false;
 }
Esempio n. 5
0
 public WaitState(DwarfGame game, string name, GameStateManager stateManager, WaitThreadRoutine routine, DwarfGUI gui)
     : base(game, name, stateManager)
 {
     WaitThread = new Thread(() => runRoutine(routine));
     GUI        = gui;
     OnFinished = (Boolean, Exception) => { };
     Done       = false;
 }
Esempio n. 6
0
        public override void OnEnter()
        {
            DefaultFont = Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Default);
            GUI         = new DwarfGUI(Game, DefaultFont, Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Title), Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Small), Input);
            Input       = new InputManager();

            CreateGUI();
            SelectedDescriptor = null;
            IsInitialized      = true;
            base.OnEnter();
        }
Esempio n. 7
0
        public override void OnEnter()
        {
            if (!MaintainState)
            {
                DefaultFont = Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Default);
                GUI         = new DwarfGUI(Game, DefaultFont,
                                           Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Default),
                                           Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Small), Input);
                IsInitialized = true;
                Logo          = TextureManager.GetTexture(ContentPaths.Logos.gamelogo);
                GUIComponent mainComponent = new GUIComponent(GUI, GUI.RootComponent)
                {
                    LocalBounds = new Rectangle(0, 0, Logo.Width, Logo.Height + 180)
                };

                AlignLayout layout = new AlignLayout(GUI, GUI.RootComponent)
                {
                    HeightSizeMode = GUIComponent.SizeMode.Fit,
                    WidthSizeMode  = GUIComponent.SizeMode.Fit,
                    Mode           = AlignLayout.PositionMode.Percent
                };

                ListSelect = new ListSelector(GUI, mainComponent)
                {
                    Label       = "- Main Menu -",
                    LocalBounds =
                        new Rectangle(Logo.Width / 2 - 150 / 2, Logo.Height + 20,
                                      150, 150)
                };


                ImagePanel logoPanel = new ImagePanel(GUI, mainComponent, Logo)
                {
                    KeepAspectRatio = true,
                    ConstrainSize   = true,
                    LocalBounds     = new Rectangle(0, 0, Logo.Width, Logo.Height)
                };

                layout.Add(mainComponent, AlignLayout.Alignment.Center, AlignLayout.Alignment.Top, Vector2.Zero);
                DefaultItems();

                ListSelect.OnItemClicked += ItemClicked;
                Drawer = new Drawer2D(Game.Content, Game.GraphicsDevice);
                Input  = new InputManager();
            }

            base.OnEnter();
        }
Esempio n. 8
0
 public MagicMenu(DwarfGUI gui, GUIComponent parent, GameMaster master, WindowButtons buttons = WindowButtons.CloseButton)
     : base(gui, parent, buttons)
 {
     Master    = master;
     MinWidth  = 512;
     MinHeight = 256;
     Selector  = new TabSelector(GUI, this, 2)
     {
         WidthSizeMode  = SizeMode.Fit,
         HeightSizeMode = SizeMode.Fit,
         LocalBounds    = new Rectangle(0, 0, MinWidth, MinHeight)
     };
     SpellTriggered = spell => { };
     CreateSpellsTab();
     CreateResearchTab();
     Selector.SetTab("Known Spells");
 }
Esempio n. 9
0
        public override void OnEnter()
        {
            PlayState.WorldWidth = Settings.Width;
            PlayState.WorldHeight = Settings.Height;
            PlayState.SeaLevel = Settings.SeaLevel;
            PlayState.Random = new ThreadSafeRandom(Seed);
            PlayState.WorldSize = new Point3(8, 1, 8);

            Overworld.Volcanoes = new List<Vector2>();

            DefaultFont = Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Default);
            GUI = new DwarfGUI(Game, DefaultFont, Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Title), Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Small), Input);
            IsInitialized = true;
            Drawer = new Drawer2D(Game.Content, Game.GraphicsDevice);
            GenerationComplete = false;
            MainWindow = new Panel(GUI, GUI.RootComponent)
            {
                LocalBounds = new Rectangle(EdgePadding, EdgePadding, Game.GraphicsDevice.Viewport.Width - EdgePadding * 2, Game.GraphicsDevice.Viewport.Height - EdgePadding * 2)
            };

            GridLayout layout = new GridLayout(GUI, MainWindow, 7, 4)
            {
                LocalBounds = new Rectangle(0, 0, MainWindow.LocalBounds.Width, MainWindow.LocalBounds.Height)
            };

            Button startButton = new Button(GUI, layout, "Start!", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.Check))
            {
                ToolTip = "Start the game with the currently generated world."
            };

            layout.SetComponentPosition(startButton, 2, 6, 1, 1);
            startButton.OnClicked += StartButtonOnClick;

            Button saveButton = new Button(GUI, layout, "Save", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.Save))
            {
                ToolTip = "Save the generated world to a file."
            };
            layout.SetComponentPosition(saveButton, 1, 6, 1, 1);
            saveButton.OnClicked += saveButton_OnClicked;

            Button exitButton = new Button(GUI, layout, "Back", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.LeftArrow))
            {
                ToolTip = "Back to the main menu."
            };
            layout.SetComponentPosition(exitButton, 0, 6, 1, 1);

            exitButton.OnClicked += ExitButtonOnClick;

            MapPanel = new ImagePanel(GUI, layout, worldMap)
            {
                ToolTip = "Map of the world.\nClick to select a location to embark."
            };

            GridLayout mapLayout = new GridLayout(GUI, MapPanel, 4, 5);

            ColorKeys = new ColorKey(GUI, mapLayout)
            {
                ColorEntries = Overworld.HeightColors
            };

            mapLayout.SetComponentPosition(ColorKeys, 3, 0, 1, 1);

            CloseupPanel = new ImagePanel(GUI, mapLayout, new ImageFrame(worldMap, new Rectangle(0, 0, 128, 128)))
            {
                KeepAspectRatio = true,
                ToolTip = "Closeup of the colony location"
            };

            mapLayout.SetComponentPosition(CloseupPanel, 3, 2, 2, 2);

            layout.SetComponentPosition(MapPanel, 0, 0, 3, 5);

            if(worldMap != null)
            {
                MapPanel.Image = new ImageFrame(worldMap);
            }

            MapPanel.OnClicked += OnMapClick;

            layout.UpdateSizes();

            GroupBox mapProperties = new GroupBox(GUI, layout, "Map Controls");

            GridLayout mapPropertiesLayout = new GridLayout(GUI, mapProperties, 7, 2)
            {
                LocalBounds = new Rectangle(mapProperties.LocalBounds.X, mapProperties.LocalBounds.Y + 32, mapProperties.LocalBounds.Width, mapProperties.LocalBounds.Height)
            };

            ComboBox worldSizeBox = new ComboBox(GUI, mapPropertiesLayout)
            {
                ToolTip = "Size of the colony spawn area."
            };

            worldSizeBox.AddValue("Tiny Colony");
            worldSizeBox.AddValue("Small Colony");
            worldSizeBox.AddValue("Medium Colony");
            worldSizeBox.AddValue("Large Colony");
            worldSizeBox.AddValue("Huge Colony");
            worldSizeBox.CurrentIndex = 1;

            worldSizeBox.OnSelectionModified += worldSizeBox_OnSelectionModified;
            mapPropertiesLayout.SetComponentPosition(worldSizeBox, 0, 0, 2, 1);

            ViewSelectionBox = new ComboBox(GUI, mapPropertiesLayout)
            {
                ToolTip = "Display type for the map."
            };

            ViewSelectionBox.AddValue("Height");
            ViewSelectionBox.AddValue("Factions");
            ViewSelectionBox.AddValue("Biomes");
            ViewSelectionBox.AddValue("Temp.");
            ViewSelectionBox.AddValue("Rain");
            ViewSelectionBox.AddValue("Erosion");
            ViewSelectionBox.AddValue("Faults");
            ViewSelectionBox.CurrentIndex = 0;

            mapPropertiesLayout.SetComponentPosition(ViewSelectionBox, 1, 1, 1, 1);

            Label selectLabel = new Label(GUI, mapPropertiesLayout, "Display", GUI.DefaultFont);
            mapPropertiesLayout.SetComponentPosition(selectLabel, 0, 1, 1, 1);
            selectLabel.Alignment = Drawer2D.Alignment.Right;

            layout.SetComponentPosition(mapProperties, 3, 0, 1, 6);

            Progress = new ProgressBar(GUI, layout, 0.0f);
            layout.SetComponentPosition(Progress, 0, 5, 3, 1);

            ViewSelectionBox.OnSelectionModified += DisplayModeModified;
            base.OnEnter();
        }
Esempio n. 10
0
        public override void OnEnter()
        {
            IsInitialized = true;

            IndicatorManager.SetupStandards();

            // TODO: Had to copy static state over from DwarfGame here. Shouldn't be necessary.
            // instead these functions should be instantiated inside LoadState.
            World = new WorldManager(Game)
            {
                WorldOrigin   = Settings.WorldOrigin,
                WorldScale    = Settings.WorldScale,
                WorldSize     = Settings.ColonySize,
                InitialEmbark = Settings.InitalEmbarkment,
                ExistingFile  = Settings.ExistingFile,
                SeaLevel      = Settings.SeaLevel,
                Natives       = Settings.Natives
            };
            World.WorldScale            = Settings.WorldScale;
            World.WorldGenerationOrigin = Settings.WorldGenerationOrigin;

            World.OnLoadedEvent += World_OnLoadedEvent;

            // Todo - Save gui creation for play state. We're only creating it here so we can give it to
            //      the world class. The world doesn't need it until after loading.
            GUI = new DwarfGUI(Game, Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Default),
                               Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Title),
                               Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Small), Input);

            GUI.ToolTipManager.InfoLocation = new Point(Game.GraphicsDevice.Viewport.Width / 2, Game.GraphicsDevice.Viewport.Height);
            GUI.MouseMode = GUISkin.MousePointer.Pointer;

            World.Setup(GUI);

            DwarfGame.GumInputMapper.GetInputQueue();
            GuiRoot = new Gum.Root(new Point(640, 480), DwarfGame.GumSkin);

            Tip = GuiRoot.RootItem.AddChild(new Gum.Widget
            {
                Font                = "outline-font",
                TextColor           = new Vector4(1, 1, 1, 1),
                MinimumSize         = new Point(0, 128),
                TextHorizontalAlign = Gum.HorizontalAlign.Center,
                TextVerticalAlign   = Gum.VerticalAlign.Center,
                Text                = "Press any key to jump!",
                AutoLayout          = Gum.AutoLayout.DockBottom
            });

            LoadTicker = GuiRoot.RootItem.AddChild(new NewGui.InfoTicker
            {
                Font       = "outline-font",
                AutoLayout = Gum.AutoLayout.DockFill,
                TextColor  = new Vector4(1, 1, 1, 1)
            }) as NewGui.InfoTicker;

            World.OnSetLoadingMessage = (s) => LoadTicker.AddMessage(s);

            GuiRoot.RootItem.Layout();

            base.OnEnter();
        }
Esempio n. 11
0
        void Initialize()
        {
            Tabs = new Dictionary<string, GUIComponent>();
            Icons = TextureManager.GetTexture(ContentPaths.GUI.icons);
            TabButtons = new List<Button>();
            GUI = new DwarfGUI(Game, Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Default), Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Title), Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Small), Input)
            {
                DebugDraw = false
            };
            IsInitialized = true;
            Drawer = new Drawer2D(Game.Content, Game.GraphicsDevice);
            MainWindow = new GUIComponent(GUI, GUI.RootComponent)
            {
                LocalBounds = new Rectangle(EdgePadding, EdgePadding, Game.GraphicsDevice.Viewport.Width - EdgePadding * 2, Game.GraphicsDevice.Viewport.Height - EdgePadding * 2)
            };
            Layout = new GridLayout(GUI, MainWindow, 11, 4);
            Layout.UpdateSizes();

            Button back = new Button(GUI, Layout, "Back", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.LeftArrow));
            Layout.SetComponentPosition(back, 0, 10, 1, 1);
            back.OnClicked += back_OnClicked;

            Panel tabPanel = new Panel(GUI, Layout);
            Layout.SetComponentPosition(tabPanel, 0, 0, 4, 1);

            GridLayout tabLayout = new GridLayout(GUI, tabPanel, 1, 10)
            {
                EdgePadding = 10
            };

               CreateTabButton(tabLayout, "Employees", "Hire and fire dwarves", 5, 0);
            EmployeeDisplay employeeDisplay = new EmployeeDisplay(GUI, Layout, PlayState.Master.Faction)
            {
                IsVisible = false
            };
            Tabs["Employees"] = employeeDisplay;

               CreateTabButton(tabLayout, "Assets", "Buy/Sell goods", 3, 1);
               GoodsPanel assetsPanel = new GoodsPanel(GUI, Layout, PlayState.Master.Faction)
               {
               IsVisible = false
               };
               Tabs["Assets"] = assetsPanel;

               CreateTabButton(tabLayout, "Capital", "Financial report", 2, 1);
               CapitalPanel capitalPanel = new CapitalPanel(GUI, Layout, PlayState.Master.Faction)
               {
               IsVisible = false
               };
               Tabs["Capital"] = capitalPanel;

              ButtonClicked(TabButtons[0]);
        }
Esempio n. 12
0
        public override void OnEnter()
        {
            DefaultFont = Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Default);
            GUI = new DwarfGUI(Game, DefaultFont, Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Title), Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Small), Input);
            Input = new InputManager();

            CreateGUI();
            SelectedDescriptor = null;
            IsInitialized = true;
            base.OnEnter();
        }
Esempio n. 13
0
        public override void OnEnter()
        {
            DefaultFont            = Game.Content.Load <SpriteFont>("Default");
            GUI                    = new DwarfGUI(Game, DefaultFont, Game.Content.Load <SpriteFont>("Title"), Game.Content.Load <SpriteFont>("Small"), Input);
            IsInitialized          = true;
            Drawer                 = new Drawer2D(Game.Content, Game.GraphicsDevice);
            MainWindow             = new Panel(GUI, GUI.RootComponent);
            MainWindow.LocalBounds = new Rectangle(EdgePadding, EdgePadding, Game.GraphicsDevice.Viewport.Width - EdgePadding * 2, Game.GraphicsDevice.Viewport.Height - EdgePadding * 2);
            Layout                 = new GridLayout(GUI, MainWindow, 10, 4);
            Label label = new Label(GUI, Layout, "GUI Elements", GUI.TitleFont);

            Layout.SetComponentPosition(label, 0, 0, 1, 1);

            Checkbox check = new Checkbox(GUI, Layout, "Check 1", GUI.DefaultFont, true);

            Layout.SetComponentPosition(check, 0, 1, 1, 1);

            Checkbox check2 = new Checkbox(GUI, Layout, "Check 2", GUI.DefaultFont, true);

            Layout.SetComponentPosition(check2, 0, 2, 1, 1);

            Button apply = new Button(GUI, Layout, "Apply", GUI.DefaultFont, Button.ButtonMode.PushButton, null);

            Layout.SetComponentPosition(apply, 2, 9, 1, 1);

            Button back = new Button(GUI, Layout, "Back", GUI.DefaultFont, Button.ButtonMode.PushButton, null);

            Layout.SetComponentPosition(back, 3, 9, 1, 1);

            Label sliderLabel = new Label(GUI, Layout, "Slider", GUI.DefaultFont);

            Layout.SetComponentPosition(sliderLabel, 0, 3, 1, 1);
            sliderLabel.Alignment = Drawer2D.Alignment.Right;

            Slider slider = new Slider(GUI, Layout, "Slider", 0, -1000, 1000, Slider.SliderMode.Integer);

            Layout.SetComponentPosition(slider, 1, 3, 1, 1);

            Label comboLabel = new Label(GUI, Layout, "Combobox", GUI.DefaultFont);

            comboLabel.Alignment = Drawer2D.Alignment.Right;

            Layout.SetComponentPosition(comboLabel, 0, 4, 1, 1);

            ComboBox combo = new ComboBox(GUI, Layout);

            combo.AddValue("Foo");
            combo.AddValue("Bar");
            combo.AddValue("Baz");
            combo.AddValue("Quz");
            combo.CurrentValue = "Foo";
            Layout.SetComponentPosition(combo, 1, 4, 1, 1);

            back.OnClicked += back_OnClicked;

            GroupBox groupBox = new GroupBox(GUI, Layout, "");

            Layout.SetComponentPosition(groupBox, 2, 1, 2, 6);
            Layout.UpdateSizes();

            /*
             * Texture2D Image = Game.Content.Load<Texture2D>("pine");
             * string[] tags = {""};
             * DraggableItem image = new DraggableItem(GUI, groupBox,new GItem("Item", new ImageFrame(Image, Image.Bounds), 0, 1, 1, tags));
             * image.LocalBounds = new Rectangle(50, 50, Image.Width, Image.Height);
             *
             * Label imageLabel = new Label(GUI, image, "Image Panel", GUI.DefaultFont);
             * imageLabel.LocalBounds = new Rectangle(0, 0, Image.Width, Image.Height);
             * imageLabel.Alignment = Drawer2D.Alignment.Top | Drawer2D.Alignment.Left;
             */

            GridLayout groupLayout = new GridLayout(GUI, groupBox, 1, 2);


            DragManager dragManager = new DragManager();

            DragGrid dragGrid  = new DragGrid(GUI, groupLayout, dragManager, 32, 32);
            DragGrid dragGrid2 = new DragGrid(GUI, groupLayout, dragManager, 32, 32);

            groupLayout.SetComponentPosition(dragGrid, 0, 0, 1, 1);
            groupLayout.SetComponentPosition(dragGrid2, 1, 0, 1, 1);
            Layout.UpdateSizes();
            groupLayout.UpdateSizes();
            dragGrid.SetupLayout();
            dragGrid2.SetupLayout();


            foreach (Resource r in ResourceLibrary.Resources.Values)
            {
                GItem gitem = new GItem(r, r.Image, r.Tint, 0, 32, 2, 1);
                gitem.CurrentAmount = 2;
                dragGrid.AddItem(gitem);
            }

            ProgressBar progress      = new ProgressBar(GUI, Layout, 0.7f);
            Label       progressLabel = new Label(GUI, Layout, "Progress Bar", GUI.DefaultFont);

            progressLabel.Alignment = Drawer2D.Alignment.Right;

            Layout.SetComponentPosition(progressLabel, 0, 5, 1, 1);
            Layout.SetComponentPosition(progress, 1, 5, 1, 1);


            LineEdit line      = new LineEdit(GUI, Layout, "");
            Label    lineLabel = new Label(GUI, Layout, "Line Edit", GUI.DefaultFont);

            lineLabel.Alignment = Drawer2D.Alignment.Right;

            Layout.SetComponentPosition(lineLabel, 0, 6, 1, 1);
            Layout.SetComponentPosition(line, 1, 6, 1, 1);

            base.OnEnter();
        }
Esempio n. 14
0
        public override void OnEnter()
        {
            PlayState.WorldWidth  = Settings.Width;
            PlayState.WorldHeight = Settings.Height;
            PlayState.SeaLevel    = Settings.SeaLevel;
            PlayState.Random      = new ThreadSafeRandom(Seed);
            PlayState.WorldSize   = new Point3(8, 1, 8);

            Overworld.Volcanoes = new List <Vector2>();

            DefaultFont        = Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Default);
            GUI                = new DwarfGUI(Game, DefaultFont, Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Title), Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Small), Input);
            IsInitialized      = true;
            Drawer             = new Drawer2D(Game.Content, Game.GraphicsDevice);
            GenerationComplete = false;
            MainWindow         = new Panel(GUI, GUI.RootComponent)
            {
                LocalBounds = new Rectangle(EdgePadding, EdgePadding, Game.GraphicsDevice.Viewport.Width - EdgePadding * 2, Game.GraphicsDevice.Viewport.Height - EdgePadding * 2)
            };

            GridLayout layout = new GridLayout(GUI, MainWindow, 7, 4)
            {
                LocalBounds = new Rectangle(0, 0, MainWindow.LocalBounds.Width, MainWindow.LocalBounds.Height)
            };

            Button startButton = new Button(GUI, layout, "Start!", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.Check))
            {
                ToolTip = "Start the game with the currently generated world."
            };

            layout.SetComponentPosition(startButton, 2, 6, 1, 1);
            startButton.OnClicked += StartButtonOnClick;

            Button saveButton = new Button(GUI, layout, "Save", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.Save))
            {
                ToolTip = "Save the generated world to a file."
            };

            layout.SetComponentPosition(saveButton, 1, 6, 1, 1);
            saveButton.OnClicked += saveButton_OnClicked;

            Button exitButton = new Button(GUI, layout, "Back", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.LeftArrow))
            {
                ToolTip = "Back to the main menu."
            };

            layout.SetComponentPosition(exitButton, 0, 6, 1, 1);

            exitButton.OnClicked += ExitButtonOnClick;


            MapPanel = new ImagePanel(GUI, layout, worldMap)
            {
                ToolTip = "Map of the world.\nClick to select a location to embark."
            };

            GridLayout mapLayout = new GridLayout(GUI, MapPanel, 4, 5);

            ColorKeys = new ColorKey(GUI, mapLayout)
            {
                ColorEntries = Overworld.HeightColors
            };

            mapLayout.SetComponentPosition(ColorKeys, 3, 0, 1, 1);

            CloseupPanel = new ImagePanel(GUI, mapLayout, new ImageFrame(worldMap, new Rectangle(0, 0, 128, 128)))
            {
                KeepAspectRatio = true,
                ToolTip         = "Closeup of the colony location"
            };

            mapLayout.SetComponentPosition(CloseupPanel, 3, 2, 2, 2);

            layout.SetComponentPosition(MapPanel, 0, 0, 3, 5);

            if (worldMap != null)
            {
                MapPanel.Image = new ImageFrame(worldMap);
            }


            MapPanel.OnClicked += OnMapClick;

            layout.UpdateSizes();

            GroupBox mapProperties = new GroupBox(GUI, layout, "Map Controls");

            GridLayout mapPropertiesLayout = new GridLayout(GUI, mapProperties, 7, 2)
            {
                LocalBounds = new Rectangle(mapProperties.LocalBounds.X, mapProperties.LocalBounds.Y + 32, mapProperties.LocalBounds.Width, mapProperties.LocalBounds.Height)
            };

            ComboBox worldSizeBox = new ComboBox(GUI, mapPropertiesLayout)
            {
                ToolTip = "Size of the colony spawn area."
            };


            worldSizeBox.AddValue("Tiny Colony");
            worldSizeBox.AddValue("Small Colony");
            worldSizeBox.AddValue("Medium Colony");
            worldSizeBox.AddValue("Large Colony");
            worldSizeBox.AddValue("Huge Colony");
            worldSizeBox.CurrentIndex = 1;

            worldSizeBox.OnSelectionModified += worldSizeBox_OnSelectionModified;
            mapPropertiesLayout.SetComponentPosition(worldSizeBox, 0, 0, 2, 1);

            ViewSelectionBox = new ComboBox(GUI, mapPropertiesLayout)
            {
                ToolTip = "Display type for the map."
            };

            ViewSelectionBox.AddValue("Height");
            ViewSelectionBox.AddValue("Factions");
            ViewSelectionBox.AddValue("Biomes");
            ViewSelectionBox.AddValue("Temp.");
            ViewSelectionBox.AddValue("Rain");
            ViewSelectionBox.AddValue("Erosion");
            ViewSelectionBox.AddValue("Faults");
            ViewSelectionBox.CurrentIndex = 0;

            mapPropertiesLayout.SetComponentPosition(ViewSelectionBox, 1, 1, 1, 1);

            Label selectLabel = new Label(GUI, mapPropertiesLayout, "Display", GUI.DefaultFont);

            mapPropertiesLayout.SetComponentPosition(selectLabel, 0, 1, 1, 1);
            selectLabel.Alignment = Drawer2D.Alignment.Right;

            layout.SetComponentPosition(mapProperties, 3, 0, 1, 6);

            Progress = new ProgressBar(GUI, layout, 0.0f);
            layout.SetComponentPosition(Progress, 0, 5, 3, 1);


            ViewSelectionBox.OnSelectionModified += DisplayModeModified;
            base.OnEnter();
        }
Esempio n. 15
0
        public override void OnEnter()
        {
            IsInitialized = true;
            DefaultFont   = Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Default);
            GUI           = new DwarfGUI(Game, DefaultFont, Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Title), Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Small), Input);
            MainWindow    = new Panel(GUI, GUI.RootComponent)
            {
                LocalBounds = new Rectangle(EdgePadding, EdgePadding, Game.GraphicsDevice.Viewport.Width - EdgePadding * 2, Game.GraphicsDevice.Viewport.Height - EdgePadding * 2)
            };
            Layout = new GridLayout(GUI, MainWindow, 10, 3);

            Label title = new Label(GUI, Layout, "Create a Company", GUI.TitleFont);

            Layout.SetComponentPosition(title, 0, 0, 1, 1);

            Label companyNameLabel = new Label(GUI, Layout, "Name", GUI.DefaultFont);

            Layout.SetComponentPosition(companyNameLabel, 0, 1, 1, 1);

            CompanyNameEdit = new LineEdit(GUI, Layout, CompanyName);
            Layout.SetComponentPosition(CompanyNameEdit, 1, 1, 1, 1);

            Button randomButton = new Button(GUI, Layout, "Random", GUI.DefaultFont, Button.ButtonMode.PushButton, null)
            {
                ToolTip = "Randomly generate a name"
            };

            Layout.SetComponentPosition(randomButton, 2, 1, 1, 1);
            randomButton.OnClicked += randomButton_OnClicked;

            Label companyMottoLabel = new Label(GUI, Layout, "Motto", GUI.DefaultFont);

            Layout.SetComponentPosition(companyMottoLabel, 0, 2, 1, 1);

            CompanyMottoEdit = new LineEdit(GUI, Layout, CompanyMotto);
            Layout.SetComponentPosition(CompanyMottoEdit, 1, 2, 1, 1);
            CompanyMottoEdit.OnTextModified += companyMottoEdit_OnTextModified;

            CompanyNameEdit.OnTextModified += companyNameEdit_OnTextModified;

            Button randomButton2 = new Button(GUI, Layout, "Random", GUI.DefaultFont, Button.ButtonMode.PushButton, null)
            {
                ToolTip = "Randomly generate a motto"
            };

            Layout.SetComponentPosition(randomButton2, 2, 2, 1, 1);
            randomButton2.OnClicked += randomButton2_OnClicked;

            Label companyLogoLabel = new Label(GUI, Layout, "Logo", GUI.DefaultFont);

            Layout.SetComponentPosition(companyLogoLabel, 0, 3, 1, 1);

            CompanyLogoPanel = new ImagePanel(GUI, Layout, CompanyLogo)
            {
                KeepAspectRatio = true,
                AssetName       = CompanyLogo.AssetName
            };
            Layout.SetComponentPosition(CompanyLogoPanel, 1, 3, 1, 1);


            Button selectorButton = new Button(GUI, Layout, "Select", GUI.DefaultFont, Button.ButtonMode.PushButton, null)
            {
                ToolTip = "Load a custom company logo"
            };

            Layout.SetComponentPosition(selectorButton, 2, 3, 1, 1);
            selectorButton.OnClicked += selectorButton_OnClicked;

            Label companyColorLabel = new Label(GUI, Layout, "Color", GUI.DefaultFont);

            Layout.SetComponentPosition(companyColorLabel, 0, 4, 1, 1);

            CompanyColorPanel = new ColorPanel(GUI, Layout)
            {
                CurrentColor = DefaultColor
            };
            Layout.SetComponentPosition(CompanyColorPanel, 1, 4, 1, 1);
            CompanyColorPanel.OnClicked += CompanyColorPanel_OnClicked;


            Button apply = new Button(GUI, Layout, "Continue", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.Check));

            Layout.SetComponentPosition(apply, 2, 9, 1, 1);

            apply.OnClicked += apply_OnClicked;

            Button back = new Button(GUI, Layout, "Back", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.LeftArrow));

            Layout.SetComponentPosition(back, 1, 9, 1, 1);

            back.OnClicked += back_onClicked;

            base.OnEnter();
        }
Esempio n. 16
0
        public override void OnEnter()
        {
            if (!MaintainState)
            {
                DefaultFont = Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Default);
                GUI = new DwarfGUI(Game, DefaultFont,
                    Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Default),
                    Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Small), Input);
                IsInitialized = true;
                Logo = TextureManager.GetTexture(ContentPaths.Logos.gamelogo);

                ListSelect = new ListSelector(GUI, GUI.RootComponent)
                {
                    Label = "- Main Menu -",
                    LocalBounds =
                        new Rectangle(Game.GraphicsDevice.Viewport.Width/2 - 100, Game.GraphicsDevice.Viewport.Height/2,
                            150, 150)
                };
                DefaultItems();

                ListSelect.OnItemClicked += ItemClicked;
                Drawer = new Drawer2D(Game.Content, Game.GraphicsDevice);
                Input = new InputManager();
            }

            base.OnEnter();
        }
Esempio n. 17
0
        /// <summary>
        /// Creates the user interface + player controls.
        /// </summary>
        /// <param name="createMaster">True if the Game Master needs to be created as well.</param>
        public void CreateGUI(bool createMaster)
        {
            LoadingMessage = "Creating GUI";
            IndicatorManager.SetupStandards();

            GUI = new DwarfGUI(Game, Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Default), Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Title), Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Small), Input);

            if(!createMaster)
            {
                return;
            }

            Master = new GameMaster(ComponentManager.Factions.Factions["Player"], Game, ComponentManager, ChunkManager, Camera, GraphicsDevice, GUI);
            CreateGUIComponents();
            GUI.MouseMode = GUISkin.MousePointer.Wait;
        }
Esempio n. 18
0
        public override void OnEnter()
        {
            DefaultFont   = Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Default);
            GUI           = new DwarfGUI(Game, DefaultFont, Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Title), Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Small), Input);
            IsInitialized = true;
            Drawer        = new Drawer2D(Game.Content, Game.GraphicsDevice);
            MainWindow    = new Panel(GUI, GUI.RootComponent)
            {
                LocalBounds = new Rectangle(EdgePadding, EdgePadding, Game.GraphicsDevice.Viewport.Width - EdgePadding * 2, Game.GraphicsDevice.Viewport.Height - EdgePadding * 2)
            };
            Layout = new GridLayout(GUI, MainWindow, 12, 6);

            Label label = new Label(GUI, Layout, "Options", GUI.TitleFont);

            Layout.SetComponentPosition(label, 0, 0, 1, 1);

            TabSelector = new TabSelector(GUI, Layout, 6);
            Layout.SetComponentPosition(TabSelector, 0, 1, 6, 10);

            TabSelector.Tab simpleGraphicsTab = TabSelector.AddTab("Graphics");
            GroupBox        simpleGraphicsBox = new GroupBox(GUI, simpleGraphicsTab, "Graphics")
            {
                WidthSizeMode  = GUIComponent.SizeMode.Fit,
                HeightSizeMode = GUIComponent.SizeMode.Fit
            };
            FormLayout simpleGraphicsLayout   = new FormLayout(GUI, simpleGraphicsBox);
            ComboBox   simpleGraphicsSelector = new ComboBox(GUI, simpleGraphicsLayout);

            simpleGraphicsSelector.AddValue("Custom");
            simpleGraphicsSelector.AddValue("Lowest");
            simpleGraphicsSelector.AddValue("Low");
            simpleGraphicsSelector.AddValue("Medium");
            simpleGraphicsSelector.AddValue("High");
            simpleGraphicsSelector.AddValue("Highest");

            simpleGraphicsLayout.AddItem("Graphics Quality", simpleGraphicsSelector);

            simpleGraphicsSelector.OnSelectionModified += simpleGraphicsSelector_OnSelectionModified;


            CreateGraphicsTab();

            TabSelector.Tab gameplayTab = TabSelector.AddTab("Gameplay");
            GroupBox        gameplayBox = new GroupBox(GUI, gameplayTab, "Gameplay")
            {
                WidthSizeMode  = GUIComponent.SizeMode.Fit,
                HeightSizeMode = GUIComponent.SizeMode.Fit
            };

            Categories["Gameplay"] = gameplayBox;

            GridLayout gameplayLayout = new GridLayout(GUI, gameplayBox, 6, 5);

            Label  moveSpeedLabel = new Label(GUI, gameplayLayout, "Camera Move Speed", GUI.DefaultFont);
            Slider moveSlider     = new Slider(GUI, gameplayLayout, "", GameSettings.Default.CameraScrollSpeed, 0.0f, 20.0f, Slider.SliderMode.Float)
            {
                ToolTip = "Determines how fast the camera will move when keys are pressed."
            };

            gameplayLayout.SetComponentPosition(moveSpeedLabel, 0, 0, 1, 1);
            gameplayLayout.SetComponentPosition(moveSlider, 1, 0, 1, 1);
            moveSlider.OnValueModified += check => { GameSettings.Default.CameraScrollSpeed = check; };

            Label  zoomSpeedLabel = new Label(GUI, gameplayLayout, "Zoom Speed", GUI.DefaultFont);
            Slider zoomSlider     = new Slider(GUI, gameplayLayout, "", GameSettings.Default.CameraZoomSpeed, 0.0f, 2.0f, Slider.SliderMode.Float)
            {
                ToolTip = "Determines how fast the camera will go\nup and down with the scroll wheel."
            };

            gameplayLayout.SetComponentPosition(zoomSpeedLabel, 0, 1, 1, 1);
            gameplayLayout.SetComponentPosition(zoomSlider, 1, 1, 1, 1);
            zoomSlider.OnValueModified += check => { GameSettings.Default.CameraZoomSpeed = check; };

            Checkbox invertZoomBox = new Checkbox(GUI, gameplayLayout, "Invert Zoom", GUI.DefaultFont, GameSettings.Default.InvertZoom)
            {
                ToolTip = "When checked, the scroll wheel is reversed\nfor zooming."
            };

            gameplayLayout.SetComponentPosition(invertZoomBox, 2, 1, 1, 1);
            invertZoomBox.OnCheckModified += check => { GameSettings.Default.InvertZoom = check; };


            Checkbox edgeScrollBox = new Checkbox(GUI, gameplayLayout, "Edge Scrolling", GUI.DefaultFont, GameSettings.Default.EnableEdgeScroll)
            {
                ToolTip = "When checked, the camera will scroll\nwhen the cursor is at the edge of the screen."
            };

            gameplayLayout.SetComponentPosition(edgeScrollBox, 0, 2, 1, 1);
            edgeScrollBox.OnCheckModified += check => { GameSettings.Default.EnableEdgeScroll = check; };

            Checkbox introBox = new Checkbox(GUI, gameplayLayout, "Play Intro", GUI.DefaultFont, GameSettings.Default.DisplayIntro)
            {
                ToolTip = "When checked, the intro will be played when the game starts"
            };

            gameplayLayout.SetComponentPosition(introBox, 1, 2, 1, 1);
            introBox.OnCheckModified += check => { GameSettings.Default.DisplayIntro = check; };

            Checkbox fogOfWarBox = new Checkbox(GUI, gameplayLayout, "Fog of War", GUI.DefaultFont, GameSettings.Default.FogofWar)
            {
                ToolTip = "When checked, unexplored blocks will be blacked out"
            };

            gameplayLayout.SetComponentPosition(fogOfWarBox, 2, 2, 1, 1);

            fogOfWarBox.OnCheckModified += check => { GameSettings.Default.FogofWar = check; };


            /*
             * Label chunkWidthLabel = new Label(GUI, gameplayLayout, "Chunk Width", GUI.DefaultFont);
             * Slider chunkWidthSlider = new Slider(GUI, gameplayLayout, "", GameSettings.Default.ChunkWidth, 4, 256, Slider.SliderMode.Integer)
             * {
             *  ToolTip = "Determines the number of blocks in a chunk of terrain."
             * };
             *
             * gameplayLayout.SetComponentPosition(chunkWidthLabel, 0, 3, 1, 1);
             * gameplayLayout.SetComponentPosition(chunkWidthSlider, 1, 3, 1, 1);
             * chunkWidthSlider.OnValueModified += ChunkWidthSlider_OnValueModified;
             *
             * Label chunkHeightLabel = new Label(GUI, gameplayLayout, "Chunk Height", GUI.DefaultFont);
             * Slider chunkHeightSlider = new Slider(GUI, gameplayLayout, "", GameSettings.Default.ChunkHeight, 4, 256, Slider.SliderMode.Integer)
             * {
             *  ToolTip = "Determines the maximum depth,\nin blocks, of a chunk of terrain."
             * };
             *
             * gameplayLayout.SetComponentPosition(chunkHeightLabel, 2, 3, 1, 1);
             * gameplayLayout.SetComponentPosition(chunkHeightSlider, 3, 3, 1, 1);
             *
             *
             * chunkHeightSlider.OnValueModified += ChunkHeightSlider_OnValueModified;
             *
             * Label worldWidthLabel = new Label(GUI, gameplayLayout, "World Width", GUI.DefaultFont);
             * Slider worldWidthSlider = new Slider(GUI, gameplayLayout, "", GameSettings.Default.WorldWidth, 4, 2048, Slider.SliderMode.Integer)
             * {
             *  ToolTip = "Determines the size of the overworld."
             * };
             *
             * gameplayLayout.SetComponentPosition(worldWidthLabel, 0, 4, 1, 1);
             * gameplayLayout.SetComponentPosition(worldWidthSlider, 1, 4, 1, 1);
             * worldWidthSlider.OnValueModified += WorldWidthSlider_OnValueModified;
             *
             * Label worldHeightLabel = new Label(GUI, gameplayLayout, "World Height", GUI.DefaultFont);
             * Slider worldHeightSlider = new Slider(GUI, gameplayLayout, "", GameSettings.Default.WorldHeight, 4, 2048, Slider.SliderMode.Integer)
             * {
             *  ToolTip = "Determines the size of the overworld."
             * };
             *
             * gameplayLayout.SetComponentPosition(worldHeightLabel, 2, 4, 1, 1);
             * gameplayLayout.SetComponentPosition(worldHeightSlider, 3, 4, 1, 1);
             * worldHeightSlider.OnValueModified += WorldHeightSlider_OnValueModified;
             *
             *
             * Label worldScaleLabel = new Label(GUI, gameplayLayout, "World Scale", GUI.DefaultFont);
             * Slider worldScaleSlider = new Slider(GUI, gameplayLayout, "", GameSettings.Default.WorldScale, 2, 128, Slider.SliderMode.Integer)
             * {
             *  ToolTip = "Determines the number of voxel\nper pixel of the overworld"
             * };
             *
             * gameplayLayout.SetComponentPosition(worldScaleLabel, 0, 5, 1, 1);
             * gameplayLayout.SetComponentPosition(worldScaleSlider, 1, 5, 1, 1);
             * worldScaleSlider.OnValueModified += WorldScaleSlider_OnValueModified;
             */

            TabSelector.Tab audioTab = TabSelector.AddTab("Audio");

            GroupBox audioBox = new GroupBox(GUI, audioTab, "Audio")
            {
                WidthSizeMode  = GUIComponent.SizeMode.Fit,
                HeightSizeMode = GUIComponent.SizeMode.Fit
            };

            Categories["Audio"] = audioBox;

            GridLayout audioLayout = new GridLayout(GUI, audioBox, 6, 5);

            Label  masterLabel  = new Label(GUI, audioLayout, "Master Volume", GUI.DefaultFont);
            Slider masterSlider = new Slider(GUI, audioLayout, "", GameSettings.Default.MasterVolume, 0.0f, 1.0f, Slider.SliderMode.Float);

            audioLayout.SetComponentPosition(masterLabel, 0, 0, 1, 1);
            audioLayout.SetComponentPosition(masterSlider, 1, 0, 1, 1);
            masterSlider.OnValueModified += value => { GameSettings.Default.MasterVolume = value; };

            Label  sfxLabel  = new Label(GUI, audioLayout, "SFX Volume", GUI.DefaultFont);
            Slider sfxSlider = new Slider(GUI, audioLayout, "", GameSettings.Default.SoundEffectVolume, 0.0f, 1.0f, Slider.SliderMode.Float);

            audioLayout.SetComponentPosition(sfxLabel, 0, 1, 1, 1);
            audioLayout.SetComponentPosition(sfxSlider, 1, 1, 1, 1);
            sfxSlider.OnValueModified += check => { GameSettings.Default.SoundEffectVolume = check; };

            Label  musicLabel  = new Label(GUI, audioLayout, "Music Volume", GUI.DefaultFont);
            Slider musicSlider = new Slider(GUI, audioLayout, "", GameSettings.Default.MusicVolume, 0.0f, 1.0f, Slider.SliderMode.Float);

            audioLayout.SetComponentPosition(musicLabel, 0, 2, 1, 1);
            audioLayout.SetComponentPosition(musicSlider, 1, 2, 1, 1);
            musicSlider.OnValueModified += check => { GameSettings.Default.MusicVolume = check; };

            TabSelector.Tab keysTab = TabSelector.AddTab("Keys");
            GroupBox        keysBox = new GroupBox(GUI, keysTab, "Keys")
            {
                WidthSizeMode  = GUIComponent.SizeMode.Fit,
                HeightSizeMode = GUIComponent.SizeMode.Fit
            };

            Categories["Keys"] = keysBox;

            KeyEditor  keyeditor = new KeyEditor(GUI, keysBox, new KeyManager(), 8, 4);
            GridLayout keyLayout = new GridLayout(GUI, keysBox, 1, 1);

            keyLayout.SetComponentPosition(keyeditor, 0, 0, 1, 1);
            keyLayout.UpdateSizes();
            keyeditor.UpdateLayout();

            /*
             * GroupBox customBox = new GroupBox(GUI, Layout, "Customization")
             * {
             *  IsVisible = false
             * };
             * Categories["Customization"] = customBox;
             * TabSelector.AddItem("Customization");
             *
             * GridLayout customBoxLayout = new GridLayout(GUI, customBox, 6, 5);
             *
             * List<string> assets = TextureManager.DefaultContent.Keys.ToList();
             *
             * AssetManager assetManager = new AssetManager(GUI, customBoxLayout, assets);
             * customBoxLayout.SetComponentPosition(assetManager, 0, 0, 5, 6);
             */

            Button apply = new Button(GUI, Layout, "Apply", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.Check));

            Layout.SetComponentPosition(apply, 5, 11, 1, 1);
            apply.OnClicked += apply_OnClicked;

            Button back = new Button(GUI, Layout, "Back", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.LeftArrow));

            Layout.SetComponentPosition(back, 4, 11, 1, 1);
            back.OnClicked += back_OnClicked;

            Layout.UpdateSizes();
            TabSelector.UpdateSize();
            TabSelector.SetTab("Graphics");
            base.OnEnter();
        }
Esempio n. 19
0
        public override void OnEnter()
        {
            DefaultFont = Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Default);
            GUI = new DwarfGUI(Game, DefaultFont, Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Title), Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Small), Input);
            IsInitialized = true;
            Drawer = new Drawer2D(Game.Content, Game.GraphicsDevice);
            MainWindow = new Panel(GUI, GUI.RootComponent)
            {
                LocalBounds = new Rectangle(EdgePadding, EdgePadding, Game.GraphicsDevice.Viewport.Width - EdgePadding * 2, Game.GraphicsDevice.Viewport.Height - EdgePadding * 2)
            };
            Layout = new GridLayout(GUI, MainWindow, 10, 6);

            Label label = new Label(GUI, Layout, "Options", GUI.TitleFont);
            Layout.SetComponentPosition(label, 0, 0, 1, 1);

            TabSelector = new TabSelector(GUI, Layout, 6);
            Layout.SetComponentPosition(TabSelector, 0, 1, 6, 8);

            TabSelector.Tab graphicsTab = TabSelector.AddTab("Graphics");

            GroupBox graphicsBox = new GroupBox(GUI, graphicsTab, "Graphics")
            {
                WidthSizeMode = GUIComponent.SizeMode.Fit,
                HeightSizeMode = GUIComponent.SizeMode.Fit
            };

            Categories["Graphics"] = graphicsBox;
            CurrentBox = graphicsBox;

            GridLayout graphicsLayout = new GridLayout(GUI, graphicsBox, 6, 5);

            Label resolutionLabel = new Label(GUI, graphicsLayout, "Resolution", GUI.DefaultFont)
            {
                Alignment = Drawer2D.Alignment.Right
            };

            ComboBox resolutionBox = new ComboBox(GUI, graphicsLayout)
            {
                ToolTip = "Sets the size of the screen.\nSmaller for higher framerates."
            };

            foreach(DisplayMode mode in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes)
            {
                if(mode.Format != SurfaceFormat.Color)
                {
                    continue;
                }

                if (mode.Width <= 640) continue;

                string s = mode.Width + " x " + mode.Height;
                DisplayModes[s] = mode;
                if(mode.Width == GameSettings.Default.ResolutionX && mode.Height == GameSettings.Default.ResolutionY)
                {
                    resolutionBox.AddValue(s);
                    resolutionBox.CurrentValue = s;
                }
                else
                {
                    resolutionBox.AddValue(s);
                }
            }

            graphicsLayout.SetComponentPosition(resolutionLabel, 0, 0, 1, 1);
            graphicsLayout.SetComponentPosition(resolutionBox, 1, 0, 1, 1);

            resolutionBox.OnSelectionModified += resolutionBox_OnSelectionModified;

            Checkbox fullscreenCheck = new Checkbox(GUI, graphicsLayout, "Fullscreen", GUI.DefaultFont, GameSettings.Default.Fullscreen)
            {
                ToolTip = "If this is checked, the game takes up the whole screen."
            };

            graphicsLayout.SetComponentPosition(fullscreenCheck, 0, 1, 1, 1);

            fullscreenCheck.OnCheckModified += fullscreenCheck_OnClicked;

            Label drawDistance = new Label(GUI, graphicsLayout, "Draw Distance", GUI.DefaultFont);
            Slider chunkDrawSlider = new Slider(GUI, graphicsLayout, "", GameSettings.Default.ChunkDrawDistance, 1, 1000, Slider.SliderMode.Integer)
            {
                ToolTip = "Maximum distance at which terrain will be drawn\nSmaller for faster."
            };

            graphicsLayout.SetComponentPosition(drawDistance, 0, 2, 1, 1);
            graphicsLayout.SetComponentPosition(chunkDrawSlider, 1, 2, 1, 1);
            chunkDrawSlider.OnValueModified += ChunkDrawSlider_OnValueModified;

            Label cullDistance = new Label(GUI, graphicsLayout, "Cull Distance", GUI.DefaultFont);
            Slider cullSlider = new Slider(GUI, graphicsLayout, "", GameSettings.Default.VertexCullDistance, 0.1f, 1000, Slider.SliderMode.Integer)
            {
                ToolTip = "Maximum distance at which anything will be drawn\n Smaller for faster."
            };

            cullSlider.OnValueModified += CullSlider_OnValueModified;

            graphicsLayout.SetComponentPosition(cullDistance, 0, 3, 1, 1);
            graphicsLayout.SetComponentPosition(cullSlider, 1, 3, 1, 1);

            Label generateDistance = new Label(GUI, graphicsLayout, "Generate Distance", GUI.DefaultFont);
            Slider generateSlider = new Slider(GUI, graphicsLayout, "", GameSettings.Default.ChunkGenerateDistance, 1, 1000, Slider.SliderMode.Integer)
            {
                ToolTip = "Maximum distance at which terrain will be generated."
            };

            generateSlider.OnValueModified += GenerateSlider_OnValueModified;

            graphicsLayout.SetComponentPosition(generateDistance, 0, 4, 1, 1);
            graphicsLayout.SetComponentPosition(generateSlider, 1, 4, 1, 1);

            Checkbox glowBox = new Checkbox(GUI, graphicsLayout, "Enable Glow", GUI.DefaultFont, GameSettings.Default.EnableGlow)
            {
                ToolTip = "When checked, there will be a fullscreen glow effect."
            };

            graphicsLayout.SetComponentPosition(glowBox, 1, 1, 1, 1);
            glowBox.OnCheckModified += glowBox_OnCheckModified;

            Label aaLabel = new Label(GUI, graphicsLayout, "Antialiasing", GUI.DefaultFont)
            {
                Alignment = Drawer2D.Alignment.Right
            };

            ComboBox aaBox = new ComboBox(GUI, graphicsLayout)
            {
                ToolTip = "Determines how much antialiasing (smoothing) there is.\nHigher means more smooth, but is slower."
            };
            aaBox.AddValue("None");
            aaBox.AddValue("FXAA");
            aaBox.AddValue("2x MSAA");
            aaBox.AddValue("4x MSAA");
            aaBox.AddValue("16x MSAA");

            foreach(string s in AAModes.Keys.Where(s => AAModes[s] == GameSettings.Default.AntiAliasing))
            {
                aaBox.CurrentValue = s;
            }

            aaBox.OnSelectionModified += AABox_OnSelectionModified;

            graphicsLayout.SetComponentPosition(aaLabel, 2, 0, 1, 1);
            graphicsLayout.SetComponentPosition(aaBox, 3, 0, 1, 1);

            Checkbox reflectTerrainBox = new Checkbox(GUI, graphicsLayout, "Reflect Chunks", GUI.DefaultFont, GameSettings.Default.DrawChunksReflected)
            {
                ToolTip = "When checked, water will reflect terrain."
            };
            reflectTerrainBox.OnCheckModified += reflectTerrainBox_OnCheckModified;
            graphicsLayout.SetComponentPosition(reflectTerrainBox, 2, 1, 1, 1);

            Checkbox refractTerrainBox = new Checkbox(GUI, graphicsLayout, "Refract Chunks", GUI.DefaultFont, GameSettings.Default.DrawChunksRefracted)
            {
                ToolTip = "When checked, water will refract terrain."
            };
            refractTerrainBox.OnCheckModified += refractTerrainBox_OnCheckModified;
            graphicsLayout.SetComponentPosition(refractTerrainBox, 2, 2, 1, 1);

            Checkbox reflectEntities = new Checkbox(GUI, graphicsLayout, "Reflect Entities", GUI.DefaultFont, GameSettings.Default.DrawEntityReflected)
            {
                ToolTip = "When checked, water will reflect trees, dwarves, etc."
            };
            reflectEntities.OnCheckModified += reflectEntities_OnCheckModified;
            graphicsLayout.SetComponentPosition(reflectEntities, 3, 1, 1, 1);

            Checkbox refractEntities = new Checkbox(GUI, graphicsLayout, "Refract Entities", GUI.DefaultFont, GameSettings.Default.DrawEntityReflected)
            {
                ToolTip = "When checked, water will reflect trees, dwarves, etc."
            };
            refractEntities.OnCheckModified += refractEntities_OnCheckModified;
            graphicsLayout.SetComponentPosition(refractEntities, 3, 2, 1, 1);

            Checkbox sunlight = new Checkbox(GUI, graphicsLayout, "Sunlight", GUI.DefaultFont, GameSettings.Default.CalculateSunlight)
            {
                ToolTip = "When checked, terrain will be lit/shadowed by the sun."
            };
            sunlight.OnCheckModified += sunlight_OnCheckModified;
            graphicsLayout.SetComponentPosition(sunlight, 2, 3, 1, 1);

            Checkbox ao = new Checkbox(GUI, graphicsLayout, "Ambient Occlusion", GUI.DefaultFont, GameSettings.Default.AmbientOcclusion)
            {
                ToolTip = "When checked, terrain will smooth shading effects."
            };
            ao.OnCheckModified += AO_OnCheckModified;
            graphicsLayout.SetComponentPosition(ao, 3, 3, 1, 1);

            Checkbox ramps = new Checkbox(GUI, graphicsLayout, "Ramps", GUI.DefaultFont, GameSettings.Default.CalculateRamps)
            {
                ToolTip = "When checked, some terrain will have smooth ramps."
            };

            ramps.OnCheckModified += ramps_OnCheckModified;
            graphicsLayout.SetComponentPosition(ramps, 2, 4, 1, 1);

            Checkbox cursorLight = new Checkbox(GUI, graphicsLayout, "Cursor Light", GUI.DefaultFont, GameSettings.Default.CursorLightEnabled)
            {
                ToolTip = "When checked, a light will follow the player cursor."
            };

            cursorLight.OnCheckModified += cursorLight_OnCheckModified;
            graphicsLayout.SetComponentPosition(cursorLight, 2, 5, 1, 1);

            Checkbox entityLight = new Checkbox(GUI, graphicsLayout, "Entity Lighting", GUI.DefaultFont, GameSettings.Default.EntityLighting)
            {
                ToolTip = "When checked, dwarves, objects, etc. will be lit\nby the sun, lamps, etc."
            };

            entityLight.OnCheckModified += entityLight_OnCheckModified;
            graphicsLayout.SetComponentPosition(entityLight, 3, 4, 1, 1);

            Checkbox selfIllum = new Checkbox(GUI, graphicsLayout, "Ore Glow", GUI.DefaultFont, GameSettings.Default.SelfIlluminationEnabled)
            {
                ToolTip = "When checked, some terrain elements will glow."
            };

            selfIllum.OnCheckModified += selfIllum_OnCheckModified;
            graphicsLayout.SetComponentPosition(selfIllum, 3, 5, 1, 1);

            Checkbox particlePhysics = new Checkbox(GUI, graphicsLayout, "Particle Body", GUI.DefaultFont, GameSettings.Default.ParticlePhysics)
            {
                ToolTip = "When checked, some particles will bounce off terrain."
            };

            particlePhysics.OnCheckModified += particlePhysics_OnCheckModified;
            graphicsLayout.SetComponentPosition(particlePhysics, 0, 5, 1, 1);

            TabSelector.Tab graphics2Tab = TabSelector.AddTab("Graphics II");
            GroupBox graphicsBox2 = new GroupBox(GUI, graphics2Tab, "Graphics II")
            {
                HeightSizeMode = GUIComponent.SizeMode.Fit,
                WidthSizeMode = GUIComponent.SizeMode.Fit
            };
            Categories["Graphics II"] = graphicsBox2;
            GridLayout graphicsLayout2 = new GridLayout(GUI, graphicsBox2, 6, 5);

            Checkbox moteBox = new Checkbox(GUI, graphicsLayout2, "Generate Motes", GUI.DefaultFont, GameSettings.Default.GrassMotes)
            {
                ToolTip = "When checked, trees, grass, etc. will be visible."
            };

            moteBox.OnCheckModified += MoteBox_OnCheckModified;
            graphicsLayout2.SetComponentPosition(moteBox, 1, 2, 1, 1);

            Label numMotes = new Label(GUI, graphicsLayout2, "Num Motes", GUI.DefaultFont);
            Slider motesSlider = new Slider(GUI, graphicsLayout2, "", (int) (GameSettings.Default.NumMotes * 100), 0, 1000, Slider.SliderMode.Integer)
            {
                ToolTip = "Determines the maximum amount of trees/grass that will be visible."
            };

            graphicsLayout2.SetComponentPosition(numMotes, 0, 1, 1, 1);
            graphicsLayout2.SetComponentPosition(motesSlider, 1, 1, 1, 1);
            motesSlider.OnValueModified += MotesSlider_OnValueModified;
            TabSelector.Tab gameplayTab = TabSelector.AddTab("Gameplay");
            GroupBox gameplayBox = new GroupBox(GUI, gameplayTab, "Gameplay")
            {
                WidthSizeMode = GUIComponent.SizeMode.Fit,
                HeightSizeMode = GUIComponent.SizeMode.Fit
            };
            Categories["Gameplay"] = gameplayBox;

            GridLayout gameplayLayout = new GridLayout(GUI, gameplayBox, 6, 5);

            Label moveSpeedLabel = new Label(GUI, gameplayLayout, "Camera Move Speed", GUI.DefaultFont);
            Slider moveSlider = new Slider(GUI, gameplayLayout, "", GameSettings.Default.CameraScrollSpeed, 0.0f, 20.0f, Slider.SliderMode.Float)
            {
                ToolTip = "Determines how fast the camera will move when keys are pressed."
            };

            gameplayLayout.SetComponentPosition(moveSpeedLabel, 0, 0, 1, 1);
            gameplayLayout.SetComponentPosition(moveSlider, 1, 0, 1, 1);
            moveSlider.OnValueModified += MoveSlider_OnValueModified;

            Label zoomSpeedLabel = new Label(GUI, gameplayLayout, "Zoom Speed", GUI.DefaultFont);
            Slider zoomSlider = new Slider(GUI, gameplayLayout, "", GameSettings.Default.CameraZoomSpeed, 0.0f, 2.0f, Slider.SliderMode.Float)
            {
                ToolTip = "Determines how fast the camera will go\nup and down with the scroll wheel."
            };

            gameplayLayout.SetComponentPosition(zoomSpeedLabel, 0, 1, 1, 1);
            gameplayLayout.SetComponentPosition(zoomSlider, 1, 1, 1, 1);
            zoomSlider.OnValueModified += ZoomSlider_OnValueModified;

            Checkbox invertZoomBox = new Checkbox(GUI, gameplayLayout, "Invert Zoom", GUI.DefaultFont, GameSettings.Default.InvertZoom)
            {
                ToolTip = "When checked, the scroll wheel is reversed\nfor zooming."
            };

            gameplayLayout.SetComponentPosition(invertZoomBox, 2, 1, 1, 1);
            invertZoomBox.OnCheckModified += InvertZoomBox_OnCheckModified;

            Checkbox edgeScrollBox = new Checkbox(GUI, gameplayLayout, "Edge Scrolling", GUI.DefaultFont, GameSettings.Default.EnableEdgeScroll)
            {
                ToolTip = "When checked, the camera will scroll\nwhen the cursor is at the edge of the screen."
            };

            gameplayLayout.SetComponentPosition(edgeScrollBox, 0, 2, 1, 1);
            edgeScrollBox.OnCheckModified += EdgeScrollBox_OnCheckModified;

            Checkbox introBox = new Checkbox(GUI, gameplayLayout, "Play Intro", GUI.DefaultFont, GameSettings.Default.DisplayIntro)
            {
                ToolTip = "When checked, the intro will be played when the game starts"
            };

            gameplayLayout.SetComponentPosition(introBox, 1, 2, 1, 1);
            introBox.OnCheckModified += IntroBox_OnCheckModified;

            Checkbox fogOfWarBox = new Checkbox(GUI, gameplayLayout, "Fog of War", GUI.DefaultFont, GameSettings.Default.FogofWar)
            {
                ToolTip = "When checked, unexplored blocks will be blacked out"
            };

            gameplayLayout.SetComponentPosition(fogOfWarBox, 2, 2, 1, 1);

            fogOfWarBox.OnCheckModified += fogOfWarBox_OnCheckModified;

            /*
            Label chunkWidthLabel = new Label(GUI, gameplayLayout, "Chunk Width", GUI.DefaultFont);
            Slider chunkWidthSlider = new Slider(GUI, gameplayLayout, "", GameSettings.Default.ChunkWidth, 4, 256, Slider.SliderMode.Integer)
            {
                ToolTip = "Determines the number of blocks in a chunk of terrain."
            };

            gameplayLayout.SetComponentPosition(chunkWidthLabel, 0, 3, 1, 1);
            gameplayLayout.SetComponentPosition(chunkWidthSlider, 1, 3, 1, 1);
            chunkWidthSlider.OnValueModified += ChunkWidthSlider_OnValueModified;

            Label chunkHeightLabel = new Label(GUI, gameplayLayout, "Chunk Height", GUI.DefaultFont);
            Slider chunkHeightSlider = new Slider(GUI, gameplayLayout, "", GameSettings.Default.ChunkHeight, 4, 256, Slider.SliderMode.Integer)
            {
                ToolTip = "Determines the maximum depth,\nin blocks, of a chunk of terrain."
            };

            gameplayLayout.SetComponentPosition(chunkHeightLabel, 2, 3, 1, 1);
            gameplayLayout.SetComponentPosition(chunkHeightSlider, 3, 3, 1, 1);

            chunkHeightSlider.OnValueModified += ChunkHeightSlider_OnValueModified;

            Label worldWidthLabel = new Label(GUI, gameplayLayout, "World Width", GUI.DefaultFont);
            Slider worldWidthSlider = new Slider(GUI, gameplayLayout, "", GameSettings.Default.WorldWidth, 4, 2048, Slider.SliderMode.Integer)
            {
                ToolTip = "Determines the size of the overworld."
            };

            gameplayLayout.SetComponentPosition(worldWidthLabel, 0, 4, 1, 1);
            gameplayLayout.SetComponentPosition(worldWidthSlider, 1, 4, 1, 1);
            worldWidthSlider.OnValueModified += WorldWidthSlider_OnValueModified;

            Label worldHeightLabel = new Label(GUI, gameplayLayout, "World Height", GUI.DefaultFont);
            Slider worldHeightSlider = new Slider(GUI, gameplayLayout, "", GameSettings.Default.WorldHeight, 4, 2048, Slider.SliderMode.Integer)
            {
                ToolTip = "Determines the size of the overworld."
            };

            gameplayLayout.SetComponentPosition(worldHeightLabel, 2, 4, 1, 1);
            gameplayLayout.SetComponentPosition(worldHeightSlider, 3, 4, 1, 1);
            worldHeightSlider.OnValueModified += WorldHeightSlider_OnValueModified;

            Label worldScaleLabel = new Label(GUI, gameplayLayout, "World Scale", GUI.DefaultFont);
            Slider worldScaleSlider = new Slider(GUI, gameplayLayout, "", GameSettings.Default.WorldScale, 2, 128, Slider.SliderMode.Integer)
            {
                ToolTip = "Determines the number of voxel\nper pixel of the overworld"
            };

            gameplayLayout.SetComponentPosition(worldScaleLabel, 0, 5, 1, 1);
            gameplayLayout.SetComponentPosition(worldScaleSlider, 1, 5, 1, 1);
            worldScaleSlider.OnValueModified += WorldScaleSlider_OnValueModified;
            */

            TabSelector.Tab audioTab = TabSelector.AddTab("Audio");

            GroupBox audioBox = new GroupBox(GUI, audioTab, "Audio")
            {
              WidthSizeMode = GUIComponent.SizeMode.Fit,
              HeightSizeMode = GUIComponent.SizeMode.Fit
            };
            Categories["Audio"] = audioBox;

            GridLayout audioLayout = new GridLayout(GUI, audioBox, 6, 5);

            Label masterLabel = new Label(GUI, audioLayout, "Master Volume", GUI.DefaultFont);
            Slider masterSlider = new Slider(GUI, audioLayout, "", GameSettings.Default.MasterVolume, 0.0f, 1.0f, Slider.SliderMode.Float);
            audioLayout.SetComponentPosition(masterLabel, 0, 0, 1, 1);
            audioLayout.SetComponentPosition(masterSlider, 1, 0, 1, 1);
            masterSlider.OnValueModified += MasterSlider_OnValueModified;

            Label sfxLabel = new Label(GUI, audioLayout, "SFX Volume", GUI.DefaultFont);
            Slider sfxSlider = new Slider(GUI, audioLayout, "", GameSettings.Default.SoundEffectVolume, 0.0f, 1.0f, Slider.SliderMode.Float);
            audioLayout.SetComponentPosition(sfxLabel, 0, 1, 1, 1);
            audioLayout.SetComponentPosition(sfxSlider, 1, 1, 1, 1);
            sfxSlider.OnValueModified += SFXSlider_OnValueModified;

            Label musicLabel = new Label(GUI, audioLayout, "Music Volume", GUI.DefaultFont);
            Slider musicSlider = new Slider(GUI, audioLayout, "", GameSettings.Default.MusicVolume, 0.0f, 1.0f, Slider.SliderMode.Float);
            audioLayout.SetComponentPosition(musicLabel, 0, 2, 1, 1);
            audioLayout.SetComponentPosition(musicSlider, 1, 2, 1, 1);
            musicSlider.OnValueModified += MusicSlider_OnValueModified;

            TabSelector.Tab keysTab = TabSelector.AddTab("Keys");
            GroupBox keysBox = new GroupBox(GUI, keysTab, "Keys")
            {
                WidthSizeMode = GUIComponent.SizeMode.Fit,
                HeightSizeMode = GUIComponent.SizeMode.Fit
            };
            Categories["Keys"] = keysBox;

            KeyEditor keyeditor = new KeyEditor(GUI, keysBox, new KeyManager(), 8, 4);
            GridLayout keyLayout = new GridLayout(GUI, keysBox, 1, 1);
            keyLayout.SetComponentPosition(keyeditor, 0, 0, 1, 1);
            keyLayout.UpdateSizes();
            keyeditor.UpdateLayout();

            /*
            GroupBox customBox = new GroupBox(GUI, Layout, "Customization")
            {
                IsVisible = false
            };
            Categories["Customization"] = customBox;
            TabSelector.AddItem("Customization");

            GridLayout customBoxLayout = new GridLayout(GUI, customBox, 6, 5);

            List<string> assets = TextureManager.DefaultContent.Keys.ToList();

            AssetManager assetManager = new AssetManager(GUI, customBoxLayout, assets);
            customBoxLayout.SetComponentPosition(assetManager, 0, 0, 5, 6);
            */

            Button apply = new Button(GUI, Layout, "Apply", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.Check));
            Layout.SetComponentPosition(apply, 5, 9, 1, 1);
            apply.OnClicked += apply_OnClicked;

            Button back = new Button(GUI, Layout, "Back", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.LeftArrow));
            Layout.SetComponentPosition(back, 4, 9, 1, 1);
            back.OnClicked += back_OnClicked;

            Layout.UpdateSizes();
            TabSelector.UpdateSize();
            TabSelector.SetTab("Graphics");
            base.OnEnter();
        }
Esempio n. 20
0
 public WaitState(DwarfGame game, string name, GameStateManager stateManager, Thread waitThread, DwarfGUI gui)
     : base(game, name, stateManager)
 {
     WaitThread = waitThread;
     GUI = gui;
     OnFinished = () => { };
     Done = false;
 }
Esempio n. 21
0
        public override void OnEnter()
        {
            IsInitialized = true;
            DefaultFont = Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Default);
            GUI = new DwarfGUI(Game, DefaultFont, Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Title), Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Small), Input);
            MainWindow = new Panel(GUI, GUI.RootComponent)
            {
                LocalBounds = new Rectangle(EdgePadding, EdgePadding, Game.GraphicsDevice.Viewport.Width - EdgePadding * 2, Game.GraphicsDevice.Viewport.Height - EdgePadding * 2)
            };
            Layout = new GridLayout(GUI, MainWindow, 10, 3);

            Label title = new Label(GUI, Layout, "Create a Company", GUI.TitleFont);
            Layout.SetComponentPosition(title, 0, 0, 1, 1);

            Label companyNameLabel = new Label(GUI, Layout, "Name", GUI.DefaultFont);
            Layout.SetComponentPosition(companyNameLabel, 0, 1, 1, 1);

            CompanyNameEdit = new LineEdit(GUI, Layout, CompanyName);
            Layout.SetComponentPosition(CompanyNameEdit, 1, 1, 1, 1);

            Button randomButton = new Button(GUI, Layout, "Random", GUI.DefaultFont, Button.ButtonMode.PushButton, null)
            {
                ToolTip = "Randomly generate a name"
            };
            Layout.SetComponentPosition(randomButton, 2, 1, 1, 1);
            randomButton.OnClicked += randomButton_OnClicked;

            Label companyMottoLabel = new Label(GUI, Layout, "Motto", GUI.DefaultFont);
            Layout.SetComponentPosition(companyMottoLabel, 0, 2, 1, 1);

            CompanyMottoEdit = new LineEdit(GUI, Layout, CompanyMotto);
            Layout.SetComponentPosition(CompanyMottoEdit, 1, 2, 1, 1);
            CompanyMottoEdit.OnTextModified += companyMottoEdit_OnTextModified;

            CompanyNameEdit.OnTextModified += companyNameEdit_OnTextModified;

            Button randomButton2 = new Button(GUI, Layout, "Random", GUI.DefaultFont, Button.ButtonMode.PushButton, null)
            {
                ToolTip = "Randomly generate a motto"
            };
            Layout.SetComponentPosition(randomButton2, 2, 2, 1, 1);
            randomButton2.OnClicked += randomButton2_OnClicked;

            Label companyLogoLabel = new Label(GUI, Layout, "Logo", GUI.DefaultFont);
            Layout.SetComponentPosition(companyLogoLabel, 0, 3, 1, 1);

            CompanyLogoPanel = new ImagePanel(GUI, Layout, CompanyLogo)
            {
                KeepAspectRatio = true,
                AssetName = CompanyLogo.AssetName
            };
            Layout.SetComponentPosition(CompanyLogoPanel, 1, 3, 1, 1);

            Button selectorButton = new Button(GUI, Layout, "Select", GUI.DefaultFont, Button.ButtonMode.PushButton, null)
            {
                ToolTip = "Load a custom company logo"
            };
            Layout.SetComponentPosition(selectorButton, 2, 3, 1, 1);
            selectorButton.OnClicked += selectorButton_OnClicked;

            Label companyColorLabel = new Label(GUI, Layout, "Color", GUI.DefaultFont);
            Layout.SetComponentPosition(companyColorLabel, 0, 4, 1, 1);

            CompanyColorPanel = new ColorPanel(GUI, Layout) {CurrentColor = DefaultColor};
            Layout.SetComponentPosition(CompanyColorPanel, 1, 4, 1, 1);
            CompanyColorPanel.OnClicked += CompanyColorPanel_OnClicked;

            Button apply = new Button(GUI, Layout, "Continue", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.Check));
            Layout.SetComponentPosition(apply, 2, 9, 1, 1);

            apply.OnClicked += apply_OnClicked;

            Button back = new Button(GUI, Layout, "Back", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.LeftArrow));
            Layout.SetComponentPosition(back, 1, 9, 1, 1);

            back.OnClicked += back_onClicked;

            base.OnEnter();
        }
Esempio n. 22
0
        public override void OnEnter()
        {
            DefaultFont   = Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Default);
            GUI           = new DwarfGUI(Game, DefaultFont, Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Title), Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Small), Input);
            IsInitialized = true;
            Drawer        = new Drawer2D(Game.Content, Game.GraphicsDevice);
            MainWindow    = new Panel(GUI, GUI.RootComponent)
            {
                LocalBounds = new Rectangle(EdgePadding, EdgePadding, Game.GraphicsDevice.Viewport.Width - EdgePadding * 2, Game.GraphicsDevice.Viewport.Height - EdgePadding * 2)
            };
            Layout = new GridLayout(GUI, MainWindow, 10, 6);

            Label label = new Label(GUI, Layout, "Options", GUI.TitleFont);

            Layout.SetComponentPosition(label, 0, 0, 1, 1);

            TabSelector = new TabSelector(GUI, Layout, 6);
            Layout.SetComponentPosition(TabSelector, 0, 1, 6, 8);

            TabSelector.Tab graphicsTab = TabSelector.AddTab("Graphics");

            GroupBox graphicsBox = new GroupBox(GUI, graphicsTab, "Graphics")
            {
                WidthSizeMode  = GUIComponent.SizeMode.Fit,
                HeightSizeMode = GUIComponent.SizeMode.Fit
            };

            Categories["Graphics"] = graphicsBox;
            CurrentBox             = graphicsBox;

            GridLayout graphicsLayout = new GridLayout(GUI, graphicsBox, 6, 5);


            Label resolutionLabel = new Label(GUI, graphicsLayout, "Resolution", GUI.DefaultFont)
            {
                Alignment = Drawer2D.Alignment.Right
            };

            ComboBox resolutionBox = new ComboBox(GUI, graphicsLayout)
            {
                ToolTip = "Sets the size of the screen.\nSmaller for higher framerates."
            };

            foreach (DisplayMode mode in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes)
            {
                if (mode.Format != SurfaceFormat.Color)
                {
                    continue;
                }

                if (mode.Width <= 640)
                {
                    continue;
                }

                string s = mode.Width + " x " + mode.Height;
                DisplayModes[s] = mode;
                if (mode.Width == GameSettings.Default.ResolutionX && mode.Height == GameSettings.Default.ResolutionY)
                {
                    resolutionBox.AddValue(s);
                    resolutionBox.CurrentValue = s;
                }
                else
                {
                    resolutionBox.AddValue(s);
                }
            }

            graphicsLayout.SetComponentPosition(resolutionLabel, 0, 0, 1, 1);
            graphicsLayout.SetComponentPosition(resolutionBox, 1, 0, 1, 1);


            resolutionBox.OnSelectionModified += resolutionBox_OnSelectionModified;

            Checkbox fullscreenCheck = new Checkbox(GUI, graphicsLayout, "Fullscreen", GUI.DefaultFont, GameSettings.Default.Fullscreen)
            {
                ToolTip = "If this is checked, the game takes up the whole screen."
            };

            graphicsLayout.SetComponentPosition(fullscreenCheck, 0, 1, 1, 1);

            fullscreenCheck.OnCheckModified += fullscreenCheck_OnClicked;


            Label  drawDistance    = new Label(GUI, graphicsLayout, "Draw Distance", GUI.DefaultFont);
            Slider chunkDrawSlider = new Slider(GUI, graphicsLayout, "", GameSettings.Default.ChunkDrawDistance, 1, 1000, Slider.SliderMode.Integer)
            {
                ToolTip = "Maximum distance at which terrain will be drawn\nSmaller for faster."
            };


            graphicsLayout.SetComponentPosition(drawDistance, 0, 2, 1, 1);
            graphicsLayout.SetComponentPosition(chunkDrawSlider, 1, 2, 1, 1);
            chunkDrawSlider.OnValueModified += ChunkDrawSlider_OnValueModified;

            Label  cullDistance = new Label(GUI, graphicsLayout, "Cull Distance", GUI.DefaultFont);
            Slider cullSlider   = new Slider(GUI, graphicsLayout, "", GameSettings.Default.VertexCullDistance, 0.1f, 1000, Slider.SliderMode.Integer)
            {
                ToolTip = "Maximum distance at which anything will be drawn\n Smaller for faster."
            };

            cullSlider.OnValueModified += CullSlider_OnValueModified;

            graphicsLayout.SetComponentPosition(cullDistance, 0, 3, 1, 1);
            graphicsLayout.SetComponentPosition(cullSlider, 1, 3, 1, 1);

            Label  generateDistance = new Label(GUI, graphicsLayout, "Generate Distance", GUI.DefaultFont);
            Slider generateSlider   = new Slider(GUI, graphicsLayout, "", GameSettings.Default.ChunkGenerateDistance, 1, 1000, Slider.SliderMode.Integer)
            {
                ToolTip = "Maximum distance at which terrain will be generated."
            };

            generateSlider.OnValueModified += GenerateSlider_OnValueModified;

            graphicsLayout.SetComponentPosition(generateDistance, 0, 4, 1, 1);
            graphicsLayout.SetComponentPosition(generateSlider, 1, 4, 1, 1);

            Checkbox glowBox = new Checkbox(GUI, graphicsLayout, "Enable Glow", GUI.DefaultFont, GameSettings.Default.EnableGlow)
            {
                ToolTip = "When checked, there will be a fullscreen glow effect."
            };

            graphicsLayout.SetComponentPosition(glowBox, 1, 1, 1, 1);
            glowBox.OnCheckModified += glowBox_OnCheckModified;

            Label aaLabel = new Label(GUI, graphicsLayout, "Antialiasing", GUI.DefaultFont)
            {
                Alignment = Drawer2D.Alignment.Right
            };

            ComboBox aaBox = new ComboBox(GUI, graphicsLayout)
            {
                ToolTip = "Determines how much antialiasing (smoothing) there is.\nHigher means more smooth, but is slower."
            };

            aaBox.AddValue("None");
            aaBox.AddValue("FXAA");
            aaBox.AddValue("2x MSAA");
            aaBox.AddValue("4x MSAA");
            aaBox.AddValue("16x MSAA");

            foreach (string s in AAModes.Keys.Where(s => AAModes[s] == GameSettings.Default.AntiAliasing))
            {
                aaBox.CurrentValue = s;
            }


            aaBox.OnSelectionModified += AABox_OnSelectionModified;

            graphicsLayout.SetComponentPosition(aaLabel, 2, 0, 1, 1);
            graphicsLayout.SetComponentPosition(aaBox, 3, 0, 1, 1);


            Checkbox reflectTerrainBox = new Checkbox(GUI, graphicsLayout, "Reflect Chunks", GUI.DefaultFont, GameSettings.Default.DrawChunksReflected)
            {
                ToolTip = "When checked, water will reflect terrain."
            };

            reflectTerrainBox.OnCheckModified += reflectTerrainBox_OnCheckModified;
            graphicsLayout.SetComponentPosition(reflectTerrainBox, 2, 1, 1, 1);

            Checkbox refractTerrainBox = new Checkbox(GUI, graphicsLayout, "Refract Chunks", GUI.DefaultFont, GameSettings.Default.DrawChunksRefracted)
            {
                ToolTip = "When checked, water will refract terrain."
            };

            refractTerrainBox.OnCheckModified += refractTerrainBox_OnCheckModified;
            graphicsLayout.SetComponentPosition(refractTerrainBox, 2, 2, 1, 1);

            Checkbox reflectEntities = new Checkbox(GUI, graphicsLayout, "Reflect Entities", GUI.DefaultFont, GameSettings.Default.DrawEntityReflected)
            {
                ToolTip = "When checked, water will reflect trees, dwarves, etc."
            };

            reflectEntities.OnCheckModified += reflectEntities_OnCheckModified;
            graphicsLayout.SetComponentPosition(reflectEntities, 3, 1, 1, 1);

            Checkbox refractEntities = new Checkbox(GUI, graphicsLayout, "Refract Entities", GUI.DefaultFont, GameSettings.Default.DrawEntityReflected)
            {
                ToolTip = "When checked, water will reflect trees, dwarves, etc."
            };

            refractEntities.OnCheckModified += refractEntities_OnCheckModified;
            graphicsLayout.SetComponentPosition(refractEntities, 3, 2, 1, 1);

            Checkbox sunlight = new Checkbox(GUI, graphicsLayout, "Sunlight", GUI.DefaultFont, GameSettings.Default.CalculateSunlight)
            {
                ToolTip = "When checked, terrain will be lit/shadowed by the sun."
            };

            sunlight.OnCheckModified += sunlight_OnCheckModified;
            graphicsLayout.SetComponentPosition(sunlight, 2, 3, 1, 1);

            Checkbox ao = new Checkbox(GUI, graphicsLayout, "Ambient Occlusion", GUI.DefaultFont, GameSettings.Default.AmbientOcclusion)
            {
                ToolTip = "When checked, terrain will smooth shading effects."
            };

            ao.OnCheckModified += AO_OnCheckModified;
            graphicsLayout.SetComponentPosition(ao, 3, 3, 1, 1);

            Checkbox ramps = new Checkbox(GUI, graphicsLayout, "Ramps", GUI.DefaultFont, GameSettings.Default.CalculateRamps)
            {
                ToolTip = "When checked, some terrain will have smooth ramps."
            };

            ramps.OnCheckModified += ramps_OnCheckModified;
            graphicsLayout.SetComponentPosition(ramps, 2, 4, 1, 1);

            Checkbox cursorLight = new Checkbox(GUI, graphicsLayout, "Cursor Light", GUI.DefaultFont, GameSettings.Default.CursorLightEnabled)
            {
                ToolTip = "When checked, a light will follow the player cursor."
            };

            cursorLight.OnCheckModified += cursorLight_OnCheckModified;
            graphicsLayout.SetComponentPosition(cursorLight, 2, 5, 1, 1);

            Checkbox entityLight = new Checkbox(GUI, graphicsLayout, "Entity Lighting", GUI.DefaultFont, GameSettings.Default.EntityLighting)
            {
                ToolTip = "When checked, dwarves, objects, etc. will be lit\nby the sun, lamps, etc."
            };

            entityLight.OnCheckModified += entityLight_OnCheckModified;
            graphicsLayout.SetComponentPosition(entityLight, 3, 4, 1, 1);

            Checkbox selfIllum = new Checkbox(GUI, graphicsLayout, "Ore Glow", GUI.DefaultFont, GameSettings.Default.SelfIlluminationEnabled)
            {
                ToolTip = "When checked, some terrain elements will glow."
            };

            selfIllum.OnCheckModified += selfIllum_OnCheckModified;
            graphicsLayout.SetComponentPosition(selfIllum, 3, 5, 1, 1);

            Checkbox particlePhysics = new Checkbox(GUI, graphicsLayout, "Particle Body", GUI.DefaultFont, GameSettings.Default.ParticlePhysics)
            {
                ToolTip = "When checked, some particles will bounce off terrain."
            };

            particlePhysics.OnCheckModified += particlePhysics_OnCheckModified;
            graphicsLayout.SetComponentPosition(particlePhysics, 0, 5, 1, 1);



            TabSelector.Tab graphics2Tab = TabSelector.AddTab("Graphics II");
            GroupBox        graphicsBox2 = new GroupBox(GUI, graphics2Tab, "Graphics II")
            {
                HeightSizeMode = GUIComponent.SizeMode.Fit,
                WidthSizeMode  = GUIComponent.SizeMode.Fit
            };

            Categories["Graphics II"] = graphicsBox2;
            GridLayout graphicsLayout2 = new GridLayout(GUI, graphicsBox2, 6, 5);

            Checkbox moteBox = new Checkbox(GUI, graphicsLayout2, "Generate Motes", GUI.DefaultFont, GameSettings.Default.GrassMotes)
            {
                ToolTip = "When checked, trees, grass, etc. will be visible."
            };

            moteBox.OnCheckModified += MoteBox_OnCheckModified;
            graphicsLayout2.SetComponentPosition(moteBox, 1, 2, 1, 1);

            Label  numMotes    = new Label(GUI, graphicsLayout2, "Num Motes", GUI.DefaultFont);
            Slider motesSlider = new Slider(GUI, graphicsLayout2, "", (int)(GameSettings.Default.NumMotes * 100), 0, 1000, Slider.SliderMode.Integer)
            {
                ToolTip = "Determines the maximum amount of trees/grass that will be visible."
            };



            graphicsLayout2.SetComponentPosition(numMotes, 0, 1, 1, 1);
            graphicsLayout2.SetComponentPosition(motesSlider, 1, 1, 1, 1);
            motesSlider.OnValueModified += MotesSlider_OnValueModified;
            TabSelector.Tab gameplayTab = TabSelector.AddTab("Gameplay");
            GroupBox        gameplayBox = new GroupBox(GUI, gameplayTab, "Gameplay")
            {
                WidthSizeMode  = GUIComponent.SizeMode.Fit,
                HeightSizeMode = GUIComponent.SizeMode.Fit
            };

            Categories["Gameplay"] = gameplayBox;

            GridLayout gameplayLayout = new GridLayout(GUI, gameplayBox, 6, 5);

            Label  moveSpeedLabel = new Label(GUI, gameplayLayout, "Camera Move Speed", GUI.DefaultFont);
            Slider moveSlider     = new Slider(GUI, gameplayLayout, "", GameSettings.Default.CameraScrollSpeed, 0.0f, 20.0f, Slider.SliderMode.Float)
            {
                ToolTip = "Determines how fast the camera will move when keys are pressed."
            };

            gameplayLayout.SetComponentPosition(moveSpeedLabel, 0, 0, 1, 1);
            gameplayLayout.SetComponentPosition(moveSlider, 1, 0, 1, 1);
            moveSlider.OnValueModified += MoveSlider_OnValueModified;

            Label  zoomSpeedLabel = new Label(GUI, gameplayLayout, "Zoom Speed", GUI.DefaultFont);
            Slider zoomSlider     = new Slider(GUI, gameplayLayout, "", GameSettings.Default.CameraZoomSpeed, 0.0f, 2.0f, Slider.SliderMode.Float)
            {
                ToolTip = "Determines how fast the camera will go\nup and down with the scroll wheel."
            };

            gameplayLayout.SetComponentPosition(zoomSpeedLabel, 0, 1, 1, 1);
            gameplayLayout.SetComponentPosition(zoomSlider, 1, 1, 1, 1);
            zoomSlider.OnValueModified += ZoomSlider_OnValueModified;

            Checkbox invertZoomBox = new Checkbox(GUI, gameplayLayout, "Invert Zoom", GUI.DefaultFont, GameSettings.Default.InvertZoom)
            {
                ToolTip = "When checked, the scroll wheel is reversed\nfor zooming."
            };

            gameplayLayout.SetComponentPosition(invertZoomBox, 2, 1, 1, 1);
            invertZoomBox.OnCheckModified += InvertZoomBox_OnCheckModified;


            Checkbox edgeScrollBox = new Checkbox(GUI, gameplayLayout, "Edge Scrolling", GUI.DefaultFont, GameSettings.Default.EnableEdgeScroll)
            {
                ToolTip = "When checked, the camera will scroll\nwhen the cursor is at the edge of the screen."
            };

            gameplayLayout.SetComponentPosition(edgeScrollBox, 0, 2, 1, 1);
            edgeScrollBox.OnCheckModified += EdgeScrollBox_OnCheckModified;

            Checkbox introBox = new Checkbox(GUI, gameplayLayout, "Play Intro", GUI.DefaultFont, GameSettings.Default.DisplayIntro)
            {
                ToolTip = "When checked, the intro will be played when the game starts"
            };

            gameplayLayout.SetComponentPosition(introBox, 1, 2, 1, 1);
            introBox.OnCheckModified += IntroBox_OnCheckModified;

            Checkbox fogOfWarBox = new Checkbox(GUI, gameplayLayout, "Fog of War", GUI.DefaultFont, GameSettings.Default.FogofWar)
            {
                ToolTip = "When checked, unexplored blocks will be blacked out"
            };

            gameplayLayout.SetComponentPosition(fogOfWarBox, 2, 2, 1, 1);

            fogOfWarBox.OnCheckModified += fogOfWarBox_OnCheckModified;


            /*
             * Label chunkWidthLabel = new Label(GUI, gameplayLayout, "Chunk Width", GUI.DefaultFont);
             * Slider chunkWidthSlider = new Slider(GUI, gameplayLayout, "", GameSettings.Default.ChunkWidth, 4, 256, Slider.SliderMode.Integer)
             * {
             *  ToolTip = "Determines the number of blocks in a chunk of terrain."
             * };
             *
             * gameplayLayout.SetComponentPosition(chunkWidthLabel, 0, 3, 1, 1);
             * gameplayLayout.SetComponentPosition(chunkWidthSlider, 1, 3, 1, 1);
             * chunkWidthSlider.OnValueModified += ChunkWidthSlider_OnValueModified;
             *
             * Label chunkHeightLabel = new Label(GUI, gameplayLayout, "Chunk Height", GUI.DefaultFont);
             * Slider chunkHeightSlider = new Slider(GUI, gameplayLayout, "", GameSettings.Default.ChunkHeight, 4, 256, Slider.SliderMode.Integer)
             * {
             *  ToolTip = "Determines the maximum depth,\nin blocks, of a chunk of terrain."
             * };
             *
             * gameplayLayout.SetComponentPosition(chunkHeightLabel, 2, 3, 1, 1);
             * gameplayLayout.SetComponentPosition(chunkHeightSlider, 3, 3, 1, 1);
             *
             *
             * chunkHeightSlider.OnValueModified += ChunkHeightSlider_OnValueModified;
             *
             * Label worldWidthLabel = new Label(GUI, gameplayLayout, "World Width", GUI.DefaultFont);
             * Slider worldWidthSlider = new Slider(GUI, gameplayLayout, "", GameSettings.Default.WorldWidth, 4, 2048, Slider.SliderMode.Integer)
             * {
             *  ToolTip = "Determines the size of the overworld."
             * };
             *
             * gameplayLayout.SetComponentPosition(worldWidthLabel, 0, 4, 1, 1);
             * gameplayLayout.SetComponentPosition(worldWidthSlider, 1, 4, 1, 1);
             * worldWidthSlider.OnValueModified += WorldWidthSlider_OnValueModified;
             *
             * Label worldHeightLabel = new Label(GUI, gameplayLayout, "World Height", GUI.DefaultFont);
             * Slider worldHeightSlider = new Slider(GUI, gameplayLayout, "", GameSettings.Default.WorldHeight, 4, 2048, Slider.SliderMode.Integer)
             * {
             *  ToolTip = "Determines the size of the overworld."
             * };
             *
             * gameplayLayout.SetComponentPosition(worldHeightLabel, 2, 4, 1, 1);
             * gameplayLayout.SetComponentPosition(worldHeightSlider, 3, 4, 1, 1);
             * worldHeightSlider.OnValueModified += WorldHeightSlider_OnValueModified;
             *
             *
             * Label worldScaleLabel = new Label(GUI, gameplayLayout, "World Scale", GUI.DefaultFont);
             * Slider worldScaleSlider = new Slider(GUI, gameplayLayout, "", GameSettings.Default.WorldScale, 2, 128, Slider.SliderMode.Integer)
             * {
             *  ToolTip = "Determines the number of voxel\nper pixel of the overworld"
             * };
             *
             * gameplayLayout.SetComponentPosition(worldScaleLabel, 0, 5, 1, 1);
             * gameplayLayout.SetComponentPosition(worldScaleSlider, 1, 5, 1, 1);
             * worldScaleSlider.OnValueModified += WorldScaleSlider_OnValueModified;
             */

            TabSelector.Tab audioTab = TabSelector.AddTab("Audio");

            GroupBox audioBox = new GroupBox(GUI, audioTab, "Audio")
            {
                WidthSizeMode  = GUIComponent.SizeMode.Fit,
                HeightSizeMode = GUIComponent.SizeMode.Fit
            };

            Categories["Audio"] = audioBox;

            GridLayout audioLayout = new GridLayout(GUI, audioBox, 6, 5);

            Label  masterLabel  = new Label(GUI, audioLayout, "Master Volume", GUI.DefaultFont);
            Slider masterSlider = new Slider(GUI, audioLayout, "", GameSettings.Default.MasterVolume, 0.0f, 1.0f, Slider.SliderMode.Float);

            audioLayout.SetComponentPosition(masterLabel, 0, 0, 1, 1);
            audioLayout.SetComponentPosition(masterSlider, 1, 0, 1, 1);
            masterSlider.OnValueModified += MasterSlider_OnValueModified;

            Label  sfxLabel  = new Label(GUI, audioLayout, "SFX Volume", GUI.DefaultFont);
            Slider sfxSlider = new Slider(GUI, audioLayout, "", GameSettings.Default.SoundEffectVolume, 0.0f, 1.0f, Slider.SliderMode.Float);

            audioLayout.SetComponentPosition(sfxLabel, 0, 1, 1, 1);
            audioLayout.SetComponentPosition(sfxSlider, 1, 1, 1, 1);
            sfxSlider.OnValueModified += SFXSlider_OnValueModified;

            Label  musicLabel  = new Label(GUI, audioLayout, "Music Volume", GUI.DefaultFont);
            Slider musicSlider = new Slider(GUI, audioLayout, "", GameSettings.Default.MusicVolume, 0.0f, 1.0f, Slider.SliderMode.Float);

            audioLayout.SetComponentPosition(musicLabel, 0, 2, 1, 1);
            audioLayout.SetComponentPosition(musicSlider, 1, 2, 1, 1);
            musicSlider.OnValueModified += MusicSlider_OnValueModified;

            TabSelector.Tab keysTab = TabSelector.AddTab("Keys");
            GroupBox        keysBox = new GroupBox(GUI, keysTab, "Keys")
            {
                WidthSizeMode  = GUIComponent.SizeMode.Fit,
                HeightSizeMode = GUIComponent.SizeMode.Fit
            };

            Categories["Keys"] = keysBox;

            KeyEditor  keyeditor = new KeyEditor(GUI, keysBox, new KeyManager(), 8, 4);
            GridLayout keyLayout = new GridLayout(GUI, keysBox, 1, 1);

            keyLayout.SetComponentPosition(keyeditor, 0, 0, 1, 1);
            keyLayout.UpdateSizes();
            keyeditor.UpdateLayout();

            /*
             * GroupBox customBox = new GroupBox(GUI, Layout, "Customization")
             * {
             *  IsVisible = false
             * };
             * Categories["Customization"] = customBox;
             * TabSelector.AddItem("Customization");
             *
             * GridLayout customBoxLayout = new GridLayout(GUI, customBox, 6, 5);
             *
             * List<string> assets = TextureManager.DefaultContent.Keys.ToList();
             *
             * AssetManager assetManager = new AssetManager(GUI, customBoxLayout, assets);
             * customBoxLayout.SetComponentPosition(assetManager, 0, 0, 5, 6);
             */

            Button apply = new Button(GUI, Layout, "Apply", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.Check));

            Layout.SetComponentPosition(apply, 5, 9, 1, 1);
            apply.OnClicked += apply_OnClicked;

            Button back = new Button(GUI, Layout, "Back", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.LeftArrow));

            Layout.SetComponentPosition(back, 4, 9, 1, 1);
            back.OnClicked += back_OnClicked;

            Layout.UpdateSizes();
            TabSelector.UpdateSize();
            TabSelector.SetTab("Graphics");
            base.OnEnter();
        }
Esempio n. 23
0
        void Initialize()
        {
            GUI = new DwarfGUI(Game, Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Default), Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Title), Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Small), Input)
            {
                DebugDraw = false
            };
            IsInitialized = true;
            Drawer = new Drawer2D(Game.Content, Game.GraphicsDevice);
            MainWindow = new Panel(GUI, GUI.RootComponent)
            {
                LocalBounds = new Rectangle(EdgePadding, EdgePadding, Game.GraphicsDevice.Viewport.Width - EdgePadding * 2, Game.GraphicsDevice.Viewport.Height - EdgePadding * 2)
            };
            Layout = new GridLayout(GUI, MainWindow, 11, 4);
            Label title = new Label(GUI, Layout, "You Lose!", GUI.TitleFont);
            Layout.SetComponentPosition(title, 0, 0, 4, 4);

            Label text = new Label(GUI, Layout,
                "The heady days of exploration for " + PlayState.Master.Faction.Economy.Company.Name +
                " are no more.\n Our stock is through the floor. Our investors have all jumped ship! \n We are going to have to sell the company. If only we had shipped more goods...",
                GUI.DefaultFont)
            {
                WordWrap = true
            };

            Layout.SetComponentPosition(text, 0, 4, 4, 4);

            Button okButton = new Button(GUI, Layout, "OK", GUI.DefaultFont, Button.ButtonMode.PushButton, null);
            okButton.OnClicked += okButton_OnClicked;
            Layout.SetComponentPosition(okButton, 2, 10, 2, 1);
            Layout.UpdateSizes();
        }
Esempio n. 24
0
        public override void OnEnter()
        {
            DefaultFont = Game.Content.Load<SpriteFont>("Default");
            GUI = new DwarfGUI(Game, DefaultFont, Game.Content.Load<SpriteFont>("Title"), Game.Content.Load<SpriteFont>("Small"), Input);
            IsInitialized = true;
            Drawer = new Drawer2D(Game.Content, Game.GraphicsDevice);
            MainWindow = new Panel(GUI, GUI.RootComponent);
            MainWindow.LocalBounds = new Rectangle(EdgePadding, EdgePadding, Game.GraphicsDevice.Viewport.Width - EdgePadding * 2, Game.GraphicsDevice.Viewport.Height - EdgePadding * 2);
            Layout = new GridLayout(GUI, MainWindow, 10, 4);
            Label label = new Label(GUI, Layout, "GUI Elements", GUI.TitleFont);
            Layout.SetComponentPosition(label, 0, 0, 1, 1);

            Checkbox check = new Checkbox(GUI, Layout, "Check 1", GUI.DefaultFont, true);
            Layout.SetComponentPosition(check, 0, 1, 1, 1);

            Checkbox check2 = new Checkbox(GUI, Layout, "Check 2", GUI.DefaultFont, true);
            Layout.SetComponentPosition(check2, 0, 2, 1, 1);

            Button apply = new Button(GUI, Layout, "Apply", GUI.DefaultFont, Button.ButtonMode.PushButton, null);
            Layout.SetComponentPosition(apply, 2, 9, 1, 1);

            Button back = new Button(GUI, Layout, "Back", GUI.DefaultFont, Button.ButtonMode.PushButton, null);
            Layout.SetComponentPosition(back, 3, 9, 1, 1);

            Label sliderLabel = new Label(GUI, Layout, "Slider", GUI.DefaultFont);
            Layout.SetComponentPosition(sliderLabel, 0, 3, 1, 1);
            sliderLabel.Alignment = Drawer2D.Alignment.Right;

            Slider slider = new Slider(GUI, Layout, "Slider", 0, -1000, 1000, Slider.SliderMode.Integer);
            Layout.SetComponentPosition(slider, 1, 3, 1, 1);

            Label comboLabel = new Label(GUI, Layout, "Combobox", GUI.DefaultFont);
            comboLabel.Alignment = Drawer2D.Alignment.Right;

            Layout.SetComponentPosition(comboLabel, 0, 4, 1, 1);

            ComboBox combo = new ComboBox(GUI, Layout);
            combo.AddValue("Foo");
            combo.AddValue("Bar");
            combo.AddValue("Baz");
            combo.AddValue("Quz");
            combo.CurrentValue = "Foo";
            Layout.SetComponentPosition(combo, 1, 4, 1, 1);

            back.OnClicked += back_OnClicked;

            GroupBox groupBox = new GroupBox(GUI, Layout, "");
            Layout.SetComponentPosition(groupBox, 2, 1, 2, 6);
            Layout.UpdateSizes();

            /*
            Texture2D Image = Game.Content.Load<Texture2D>("pine");
            string[] tags = {""};
            DraggableItem image = new DraggableItem(GUI, groupBox,new GItem("Item", new ImageFrame(Image, Image.Bounds), 0, 1, 1, tags));
            image.LocalBounds = new Rectangle(50, 50, Image.Width, Image.Height);

            Label imageLabel = new Label(GUI, image, "Image Panel", GUI.DefaultFont);
            imageLabel.LocalBounds = new Rectangle(0, 0, Image.Width, Image.Height);
            imageLabel.Alignment = Drawer2D.Alignment.Top | Drawer2D.Alignment.Left;
            */

            GridLayout groupLayout = new GridLayout(GUI, groupBox, 1, 2);

            DragManager dragManager = new DragManager();

            DragGrid dragGrid = new DragGrid(GUI, groupLayout, dragManager, 32, 32);
            DragGrid dragGrid2 = new DragGrid(GUI, groupLayout, dragManager, 32, 32);

            groupLayout.SetComponentPosition(dragGrid, 0, 0, 1, 1);
            groupLayout.SetComponentPosition(dragGrid2, 1, 0, 1, 1);
            Layout.UpdateSizes();
            groupLayout.UpdateSizes();
            dragGrid.SetupLayout();
            dragGrid2.SetupLayout();

            foreach(Resource r in ResourceLibrary.Resources.Values)
            {
                if(r.ResourceName != "Container")
                {
                    GItem gitem = new GItem(r.ResourceName, r.Image, 0, 32, 2, 1);
                    gitem.CurrentAmount = 2;
                    dragGrid.AddItem(gitem);
                }
            }

            ProgressBar progress = new ProgressBar(GUI, Layout, 0.7f);
            Label progressLabel = new Label(GUI, Layout, "Progress Bar", GUI.DefaultFont);
            progressLabel.Alignment = Drawer2D.Alignment.Right;

            Layout.SetComponentPosition(progressLabel, 0, 5, 1, 1);
            Layout.SetComponentPosition(progress, 1, 5, 1, 1);

            LineEdit line = new LineEdit(GUI, Layout, "");
            Label lineLabel = new Label(GUI, Layout, "Line Edit", GUI.DefaultFont);
            lineLabel.Alignment = Drawer2D.Alignment.Right;

            Layout.SetComponentPosition(lineLabel, 0, 6, 1, 1);
            Layout.SetComponentPosition(line, 1, 6, 1, 1);

            base.OnEnter();
        }