public override void Initialize() { Viewport vp = manager.UI.GraphicsDevice.Viewport; settings = new ControlGroup(); int pad = (int)(0.05f * vp.Width); Rectangle pArea = new Rectangle(pad, (int)(0.15f * vp.Height), vp.Width - 2 * pad, (int)(0.35f * vp.Height)); settings.Add(new Panel("Main Panel", pArea, new Color(0, 0, 0, 100))); settings.Add(new Label("Graphics Settings", new Rectangle(pArea.X, pArea.Y, pArea.Width, (int)Fonts.Arial.MeasureString("Graphics Settings").Y), Label.Fit.AlignCenter)); ControlMat mat = new ControlMat(pArea, 4, 3, 5); Checkbox drawDetailBox = new Checkbox("Terrain Detail", new Rectangle(0, 0, 50, 50)); drawDetailBox.SetState(Sim.Settings.Graphics.Default.TerrainDetail); drawDetailBox.StateChanged += delegate() { Sim.Settings.Graphics.Default.TerrainDetail = drawDetailBox.State; }; settings.Add(drawDetailBox); int bHeight = (int)(0.05f * vp.Height); int bWidth = (int)(0.125f * vp.Width); Button backButton = new Button("Back", new Rectangle(pad, vp.Height - bHeight - pad, bWidth, bHeight), delegate() { manager.ChangeScreen(new MenuScreen(manager)); }); settings.Add(backButton); Button applyButton = new Button("Apply", new Rectangle(vp.Width - bWidth - pad, backButton.Area.Y, bWidth, bHeight), delegate() { }); settings.Add(applyButton); }
private void SetupComponents(Viewport vp, int pad) { int bHeight = (int)(0.05f * vp.Height); int bWidth = (int)(0.125f * vp.Width); Panel hmPanelBG = new Panel("HM Img BG", new Rectangle(pad, 2 * pad, vp.Width / 3, vp.Width / 3), new Color(0,0,0,128)); controls.Add(hmPanelBG); Panel hmPanel = new Panel("Heightmap Img", new Rectangle(hmPanelBG.Area.X + 5, hmPanelBG.Area.Y + 5, hmPanelBG.Area.Width - 10, hmPanelBG.Area.Height - 10), Color.White); hmPanel.Texture = Textures.Heightmaps[bs.HMIndex]; controls.Add(hmPanel); // area where settings components are displayed Rectangle settingsPanelArea = new Rectangle(pad + hmPanel.Area.Right, 2 * pad, vp.Width - hmPanel.Area.Width - pad * 3, hmPanelBG.Area.Height); Panel settingsPanel = new Panel("Settings", settingsPanelArea, new Color(0, 0, 0, 128)); controls.Add(settingsPanel); // setup the settings components for each tab SetupTerrainComponents(vp, settingsPanelArea); // button used to return to menu Button cancelButton = new Button("Cancel", new Rectangle(pad, vp.Height - bHeight - pad, bWidth, bHeight), delegate() { manager.ChangeScreen(new MenuScreen(manager)); }); controls.Add(cancelButton); // button used to build the world Button buildButton = new Button("Build", new Rectangle(vp.Width - bWidth - pad, cancelButton.Area.Y, bWidth, bHeight), BuildWorld); controls.Add(buildButton); // button used to display previous heightmap Button prevButton = new Button("<", new Rectangle(pad, hmPanel.Area.Bottom + pad / 2, bWidth, bHeight), delegate() { hmPanel.Texture = Textures.Heightmaps[bs.HMIndex = bs.HMIndex == 0 ? Textures.Heightmaps.Length - 1 : --bs.HMIndex]; }); controls.Add(prevButton); // button used to display next heightmap Button nextButton = new Button(">", new Rectangle(hmPanel.Area.Right - bWidth, prevButton.Area.Y, bWidth, bHeight), delegate() { hmPanel.Texture = Textures.Heightmaps[bs.HMIndex = bs.HMIndex == Textures.Heightmaps.Length - 1 ? 0 : ++bs.HMIndex]; }); controls.Add(nextButton); }