Exemplo n.º 1
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();
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
0
        private void CreateGraphicsTab()
        {
            TabSelector.Tab graphicsTab = null;

            if (!TabSelector.Tabs.ContainsKey("Advanced Graphics"))
            {
                graphicsTab = TabSelector.AddTab("Advanced Graphics");
            }
            else
            {
                graphicsTab = TabSelector.Tabs["Advanced Graphics"];
                graphicsTab.Reset();
            }
            GridLayout tabLayout = new GridLayout(GUI, graphicsTab, 1, 1);

            ScrollView graphicsView = new ScrollView(GUI, tabLayout);

            tabLayout.SetComponentPosition(graphicsView, 0, 0, 1, 1);

            GroupBox graphicsBox = new GroupBox(GUI, graphicsView, "Advanced Graphics")
            {
                WidthSizeMode  = GUIComponent.SizeMode.Fit,
                HeightSizeMode = GUIComponent.SizeMode.Fixed,
                MinHeight      = 640,
                MaxHeight      = 640
            };

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

            GridLayout graphicsLayout = new GridLayout(GUI, graphicsBox, 10, 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 += s =>
            {
                GameSettings.Default.ResolutionX = DisplayModes[s].Width;
                GameSettings.Default.ResolutionY = DisplayModes[s].Height;
            };

            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 += b => { GameSettings.Default.Fullscreen = b; };


            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 += b => { GameSettings.Default.ChunkDrawDistance = b; };

            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 += v => { GameSettings.Default.VertexCullDistance = v; };

            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 += v => { GameSettings.Default.ChunkGenerateDistance = v; };

            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 += b => { GameSettings.Default.EnableGlow = b; };

            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 += s => { GameSettings.Default.AntiAliasing = AAModes[s]; };

            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 += b => { GameSettings.Default.DrawChunksReflected = b; };
            graphicsLayout.SetComponentPosition(reflectTerrainBox, 2, 1, 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 += b => { GameSettings.Default.DrawEntityReflected = b; };
            graphicsLayout.SetComponentPosition(reflectEntities, 3, 1, 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 += b => { GameSettings.Default.CalculateSunlight = b; };
            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 += b => { GameSettings.Default.AmbientOcclusion = b; };
            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 += b => { GameSettings.Default.CalculateRamps = b; };
            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 += b => { GameSettings.Default.CursorLightEnabled = b; };
            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 += b => { GameSettings.Default.EntityLighting = b; };
            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 += b => { GameSettings.Default.SelfIlluminationEnabled = b; };
            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 += b => { GameSettings.Default.ParticlePhysics = b; };
            graphicsLayout.SetComponentPosition(particlePhysics, 0, 5, 1, 1);

            Checkbox moteBox = new Checkbox(GUI, graphicsLayout, "Generate Motes", GUI.DefaultFont,
                                            GameSettings.Default.GrassMotes)
            {
                ToolTip = "When checked, small detail vegetation will be visible."
            };

            moteBox.OnCheckModified += check => { GameSettings.Default.GrassMotes = check; };
            graphicsLayout.SetComponentPosition(moteBox, 0, 6, 1, 1);

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

            graphicsLayout.SetComponentPosition(numMotes, 0, 7, 1, 1);
            graphicsLayout.SetComponentPosition(motesSlider, 1, 7, 1, 1);


            Checkbox lightMapBox = new Checkbox(GUI, graphicsLayout, "Light Maps", GUI.DefaultFont,
                                                GameSettings.Default.UseLightmaps)
            {
                ToolTip = "When checked, terrain will be rendered using light maps."
            };

            lightMapBox.OnCheckModified += check => { GameSettings.Default.UseLightmaps = check; };

            graphicsLayout.SetComponentPosition(lightMapBox, 0, 8, 1, 1);


            Checkbox shadowBox = new Checkbox(GUI, graphicsLayout, "Dynamic Shadows", GUI.DefaultFont,
                                              GameSettings.Default.UseLightmaps)
            {
                ToolTip = "When checked, terrain casts dynamic shadows"
            };

            shadowBox.OnCheckModified += check => { GameSettings.Default.UseDynamicShadows = check; };

            graphicsLayout.SetComponentPosition(shadowBox, 0, 9, 1, 1);

            motesSlider.OnValueModified += MotesSlider_OnValueModified;
        }
Exemplo n.º 4
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();
        }
Exemplo n.º 5
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();
        }
Exemplo 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);
            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();
        }
Exemplo n.º 7
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();
        }
Exemplo n.º 8
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();
        }