public void Draw(GUICanvas canvas) { //if (!GameSettings.ui_DrawUI) return; _foregroundIndex = 0; //_graphicsDevice.SetRenderTarget(null); _graphicsDevice.RasterizerState = RasterizerState.CullNone; _spriteBatch.Begin(); canvas.Draw(this, Vector2.Zero, GUIControl.GetMousePosition()); //Now draw foregroundImages for (int index = 0; index <= _foregroundIndex - 1; index++) { ForegroundImage image = foregroundImages[index]; DrawImage(image.pos, image.dim, image.tex, image.color, false); } _spriteBatch.End(); }
public void Update(GameTime gameTime, bool isActive, TransformableObject selectedObject) { GameStats.UIIsHovered = false; if (!isActive || !GameSettings.e_enableeditor || !GameSettings.ui_enabled) return; if (GameStats.e_gizmoMode != _gizmoModePrevious) { _gizmoModePrevious = GameStats.e_gizmoMode; UpdateGizmoSelection(_gizmoModePrevious); } GUIControl.Update(Input.mouseLastState, Input.mouseState); if (GUIControl.GetMousePosition().X > _rightSideList.Position.X && GUIControl.GetMousePosition().Y < _rightSideList.Dimensions.Y) { GameStats.UIIsHovered = true; } _leftSideList.IsHidden = !GameStats.e_EnableSelection; if (selectedObject != null) { //Check if cached, otherwise apply if (activeObjectName != selectedObject.Name || activeObjectPos != selectedObject.Position) { _objectDescriptionList.IsHidden = false; _objectDescriptionName.Text.Clear(); _objectDescriptionName.Text.Append(selectedObject.Name); _objectDescriptionName.TextAlignment = GUIStyle.TextAlignment.Center; _objectDescriptionPos.Text.Clear(); _objectDescriptionPos.Text.AppendVector3(selectedObject.Position); _objectDescriptionPos.TextAlignment = GUIStyle.TextAlignment.Center; activeObjectName = selectedObject.Name; activeObjectPos = selectedObject.Position; } _objectButton1.IsHidden = true; _objectToggle0.IsHidden = true; _objectToggle1.IsHidden = true; _objectToggle2.IsHidden = true; _objectToggle3.IsHidden = true; _objectSlider0.IsHidden = true; _objectSlider1.IsHidden = true; _objectSlider2.IsHidden = true; _objectColorPicker1.IsHidden = true; if (selectedObject is PointLight) { _objectToggle0.IsHidden = false; _objectToggle1.IsHidden = false; _objectToggle2.IsHidden = false; _objectToggle3.IsHidden = false; _objectSlider0.IsHidden = false; _objectSlider1.IsHidden = false; _objectSlider2.IsHidden = false; _objectColorPicker1.IsHidden = false; if (activeObject != selectedObject) { _objectToggle0.SetProperty(selectedObject, "IsEnabled"); _objectToggle0.Text = new StringBuilder("IsEnabled"); _objectToggle1.SetField(selectedObject, "IsVolumetric"); _objectToggle1.Text = new StringBuilder("Volumetric"); _objectToggle2.SetField(selectedObject, "CastShadows"); _objectToggle2.Text = new StringBuilder("Cast Shadows"); _objectToggle3.SetField(selectedObject, "CastSDFShadows"); _objectToggle3.Text = new StringBuilder("Cast SDF Shadows"); _objectSlider0.MinValue = 1.1f; _objectSlider0.MaxValue = 200; _objectSlider0.SetProperty(selectedObject, "Radius"); _objectSlider0.SetText(new StringBuilder("Radius: ")); _objectSlider1.MinValue = 0.01f; _objectSlider1.MaxValue = 1000; _objectSlider1.SetField(selectedObject, "Intensity"); _objectSlider1.SetText(new StringBuilder("Intensity: ")); _objectSlider2.SetValues("Shadow Softness: ", 1, 20, 1); _objectSlider2.SetField(selectedObject, "ShadowMapRadius"); _objectColorPicker1.SetProperty(selectedObject, "Color"); } } else if (selectedObject is DirectionalLight) { _objectToggle0.IsHidden = false; _objectToggle2.IsHidden = false; _objectSlider1.IsHidden = false; _objectColorPicker1.IsHidden = false; if (activeObject != selectedObject) { _objectToggle0.SetProperty(selectedObject, "IsEnabled"); _objectToggle0.Text = new StringBuilder("IsEnabled"); _objectToggle2.SetField(selectedObject, "CastShadows"); _objectToggle2.Text = new StringBuilder("Cast Shadows"); _objectSlider1.MinValue = 0.01f; _objectSlider1.MaxValue = 1000; _objectSlider1.SetField(selectedObject, "Intensity"); _objectSlider1.SetText(new StringBuilder("Intensity: ")); _objectColorPicker1.SetProperty(selectedObject, "Color"); } } // Environment Sample! else if(selectedObject is EnvironmentSample) { _objectButton1.IsHidden = false; _objectToggle1.IsHidden = false; _objectToggle2.IsHidden = false; _objectSlider0.IsHidden = false; _objectSlider1.IsHidden = false; if (activeObject != selectedObject) { _objectButton1.ButtonObject = selectedObject; _objectButton1.ButtonMethod = selectedObject.GetType().GetMethod("Update"); _objectButton1.Text = new StringBuilder("Update Cubemap"); _objectToggle1.ToggleObject = selectedObject; _objectToggle1.ToggleField = selectedObject.GetType().GetField("AutoUpdate"); _objectToggle1.Toggle = (selectedObject as EnvironmentSample).AutoUpdate; _objectToggle1.Text = new StringBuilder("Update on move"); _objectToggle2.SetField(selectedObject, "UseSDFAO"); _objectToggle2.Text = new StringBuilder("Use SDFAO"); _objectSlider0.SetField(selectedObject, "SpecularStrength"); _objectSlider0.SetValues("Specular Strength: ", 0.01f, 1, 2); _objectSlider1.SetField(selectedObject, "DiffuseStrength"); _objectSlider1.SetValues("Diffuse Strength: ", 0, 1, 2); } } else if (selectedObject is DebugEntity) { _objectSlider0.IsHidden = false; _objectSlider1.IsHidden = false; _objectSlider2.IsHidden = false; if (activeObject != selectedObject) { //_objectSlider0.SetProperty(selectedObject, "SizeX"); //_objectSlider0.SetValues("Size X: ", 0.1f, 200, 2); //_objectSlider1.SetProperty(selectedObject, "SizeY"); //_objectSlider1.SetValues("Size Y: ", 0.1f, 200, 2); //_objectSlider2.SetProperty(selectedObject, "SizeZ"); //_objectSlider2.SetValues("Size Z: ", 0.1f, 200, 2); } } activeObject = selectedObject; } else { _objectDescriptionList.IsHidden = true; } GuiCanvas.Update(gameTime, GUIControl.GetMousePosition(), Vector2.Zero); }