public override void Draw(SpriteBatch spriteBatch) { if (!Visible) { return; } frame.Draw(spriteBatch); if (!scrollBarHidden) { scrollBar.Draw(spriteBatch); } Rectangle prevScissorRect = spriteBatch.GraphicsDevice.ScissorRectangle; spriteBatch.GraphicsDevice.ScissorRectangle = Rectangle.Intersect(prevScissorRect, frame.Rect); int lastVisible = 0; for (int i = 0; i < children.Count; i++) { GUIComponent child = children[i]; if (child == frame || !child.Visible) { continue; } if (!IsChildVisible(child)) { if (lastVisible > 0) { break; } continue; } lastVisible = i; child.Draw(spriteBatch); } spriteBatch.GraphicsDevice.ScissorRectangle = prevScissorRect; }
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch) { cam.UpdateTransform(); GameMain.ParticleManager.UpdateTransforms(); //------------------------------------------------------- spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, cam.Transform); graphics.Clear(new Color(0.051f, 0.149f, 0.271f, 1.0f)); GameMain.ParticleManager.Draw(spriteBatch, false, false, ParticleBlendState.AlphaBlend); GameMain.ParticleManager.Draw(spriteBatch, true, false, ParticleBlendState.AlphaBlend); spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.Additive, null, null, null, null, cam.Transform); GameMain.ParticleManager.Draw(spriteBatch, false, false, ParticleBlendState.Additive); GameMain.ParticleManager.Draw(spriteBatch, true, false, ParticleBlendState.Additive); spriteBatch.End(); //------------------------------------------------------- spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, GameMain.ScissorTestEnable); guiRoot.Draw(spriteBatch); GUI.Draw((float)deltaTime, spriteBatch, cam); spriteBatch.End(); }
/// <summary> /// This is called when the game should draw itself. /// </summary> public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch) { cam.UpdateTransform(); spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, cam.Transform); graphics.Clear(new Color(0.051f, 0.149f, 0.271f, 1.0f)); if (GameMain.DebugDraw) { GUI.DrawLine(spriteBatch, new Vector2(Submarine.MainSub.HiddenSubPosition.X, -cam.WorldView.Y), new Vector2(Submarine.MainSub.HiddenSubPosition.X, -(cam.WorldView.Y - cam.WorldView.Height)), Color.White * 0.5f, 1.0f, (int)(2.0f / cam.Zoom)); GUI.DrawLine(spriteBatch, new Vector2(cam.WorldView.X, -Submarine.MainSub.HiddenSubPosition.Y), new Vector2(cam.WorldView.Right, -Submarine.MainSub.HiddenSubPosition.Y), Color.White * 0.5f, 1.0f, (int)(2.0f / cam.Zoom)); } Submarine.Draw(spriteBatch, true); if (!characterMode && !wiringMode) { if (MapEntityPrefab.Selected != null) { MapEntityPrefab.Selected.DrawPlacing(spriteBatch, cam); } MapEntity.DrawSelecting(spriteBatch, cam); } spriteBatch.End(); //-------------------- HUD ----------------------------- spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, GameMain.ScissorTestEnable); if (Submarine.MainSub != null) { DrawSubmarineIndicator(spriteBatch, Submarine.MainSub, Color.LightBlue * 0.5f); } leftPanel.Draw(spriteBatch); topPanel.Draw(spriteBatch); //EntityPrefab.DrawList(spriteBatch, new Vector2(20,50)); if ((characterMode || wiringMode) && dummyCharacter != null) { if (dummyCharacter.SelectedConstruction != null) { dummyCharacter.SelectedConstruction.DrawHUD(spriteBatch, cam, dummyCharacter); } dummyCharacter.DrawHUD(spriteBatch, cam); if (wiringMode) { wiringToolPanel.Draw(spriteBatch); } } else { if (loadFrame != null) { loadFrame.Draw(spriteBatch); } else if (saveFrame != null) { saveFrame.Draw(spriteBatch); } else if (selectedTab > -1) { GUItabs[selectedTab].Draw(spriteBatch); } MapEntity.DrawEditor(spriteBatch, cam); } if (tutorial != null) { tutorial.Draw(spriteBatch); } GUI.Draw((float)deltaTime, spriteBatch, cam); if (!PlayerInput.LeftButtonHeld()) { Inventory.draggingItem = null; } spriteBatch.End(); }
/// <summary> /// This is called when the game should draw itself. /// </summary> public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch) { //cam.UpdateTransform(); graphics.Clear(Color.CornflowerBlue); spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, cam.Transform); Submarine.Draw(spriteBatch, true); spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, cam.Transform); //if (EntityPrefab.Selected != null) EntityPrefab.Selected.UpdatePlacing(spriteBatch, cam); //Entity.DrawSelecting(spriteBatch, cam); if (editingCharacter != null) { editingCharacter.Draw(spriteBatch); } spriteBatch.End(); //-------------------- HUD ----------------------------- spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, GameMain.ScissorTestEnable); GUIpanel.Draw(spriteBatch); EditLimb(spriteBatch); int y = 0; for (int i = 0; i < textures.Count; i++) { int x = GameMain.GraphicsWidth - textures[i].Width; spriteBatch.Draw(textures[i], new Vector2(x, y), Color.White); foreach (Limb limb in editingCharacter.AnimController.Limbs) { if (limb.sprite == null || limb.sprite.FilePath != texturePaths[i]) { continue; } Rectangle rect = limb.sprite.SourceRect; rect.X += x; rect.Y += y; GUI.DrawRectangle(spriteBatch, rect, Color.Red); Vector2 limbBodyPos = new Vector2( rect.X + limb.sprite.Origin.X, rect.Y + limb.sprite.Origin.Y); DrawJoints(spriteBatch, limb, limbBodyPos); //if (limb.BodyShapeTexture == null) continue; //spriteBatch.Draw(limb.BodyShapeTexture, limbBodyPos, // null, Color.White, 0.0f, // new Vector2(limb.BodyShapeTexture.Width, limb.BodyShapeTexture.Height) / 2, // 1.0f, SpriteEffects.None, 0.0f); GUI.DrawLine(spriteBatch, limbBodyPos + Vector2.UnitY * 5.0f, limbBodyPos - Vector2.UnitY * 5.0f, Color.White); GUI.DrawLine(spriteBatch, limbBodyPos + Vector2.UnitX * 5.0f, limbBodyPos - Vector2.UnitX * 5.0f, Color.White); if (Vector2.Distance(PlayerInput.MousePosition, limbBodyPos) < 5.0f && PlayerInput.LeftButtonHeld()) { limb.sprite.Origin += PlayerInput.MouseSpeed; } } y += textures[i].Height; } GUI.Draw((float)deltaTime, spriteBatch, cam); //EntityPrefab.DrawList(spriteBatch, new Vector2(20,50)); //Entity.Edit(spriteBatch, cam); spriteBatch.End(); }