public void AnchorDrawing(DebugObject obj) { SpriteBatch.Draw( texture: TextureLoader.TheOnePixel, destinationRectangle: new Rectangle((int)obj.Position.X, (int)obj.Position.Y, (int)TextureLoader.Font.MeasureString(obj.ToString()).X, (int)TextureLoader.Font.MeasureString(obj.ToString()).Y), color: Color.Black * 0.4f); SpriteBatch.DrawString(TextureLoader.Font, obj.ToString(), obj.Position, Color.White); SpriteBatch.DrawString(TextureLoader.Font, "Anchored", obj.item.Position, Color.Crimson); SpriteBatch.Draw( texture: TextureLoader.TheOnePixel, destinationRectangle: new Rectangle((int)obj.item.Position.X, (int)obj.item.Position.Y, obj.item.TextureWidth, obj.item.TextureHeight), color: Color.Black * 0.4f); SpriteBatch.Draw( texture: TextureLoader.TheOnePixel, destinationRectangle: new Rectangle((int)obj.item.BoundingBoxX, (int)obj.item.BoundingBoxY, obj.item.BoundingBox.Width, obj.item.BoundingBox.Height), color: Color.Black * 0.4f); }
public void DisplayObjectProps(IGameObject obj) { var toDraw = new DebugObject(obj); toDraw.Position = new Vector2(0, 0); SpriteBatch.Draw( texture: TextureLoader.TheOnePixel, destinationRectangle: new Rectangle((int)toDraw.Position.X, (int)toDraw.Position.Y, (int)TextureLoader.Font.MeasureString(toDraw.ToString()).X, (int)TextureLoader.Font.MeasureString(toDraw.ToString()).Y), color: Color.Black * 0.4f); SpriteBatch.DrawString(TextureLoader.Font, toDraw.ToString(), toDraw.Position, Color.White); }
/// <summary> /// /// </summary> /// <param name="item"></param> private void Anchor(DebugObject item) { bool contains = this.AnchoredObjects.Any(p => p.Id == item.Id); if (!contains) { item.Position = new Vector2(this.indent, 0); this.AnchoredObjects.AddLast(new LinkedListNode <DebugObject>(item)); this.indent += (int)TextureLoader.Font.MeasureString(item.LongestLine).X; } else { var toRemove = this.AnchoredObjects.First(e => e.Id == item.Id); this.indent -= (int)TextureLoader.Font.MeasureString(item.LongestLine).X; for (var i = AnchoredObjects.Last.Value; i != AnchoredObjects.Find(toRemove).Value; i = AnchoredObjects.Find(i).Previous.Value) { i.Position = AnchoredObjects.Find(i).Previous.Value.Position; } this.AnchoredObjects.Remove(toRemove); } }
//TODO: Figure a way to get mouse position relative to the current position because //if in window Mouse.GetState() returns point relative to the border of the window public void StatsOnHover() { previousMouseState = currentMouseState; currentMouseState = Mouse.GetState(); foreach (var item in Engine.Objects) { if (item.BoundingBox.Contains(this.MousePosition.ToVector2())) { HoverDrawing(item); if (currentMouseState.LeftButton == ButtonState.Pressed && previousMouseState.LeftButton == ButtonState.Released) { var debugObj = new DebugObject(item); Anchor(debugObj); } } } foreach (var item in AnchoredObjects) { AnchorDrawing(item); } }
public void HoverDrawing(IGameObject obj) { SpriteBatch.DrawString(TextureLoader.Font, DebugObject.toString(obj), obj.Position, Color.White); }
public void DisplayObjectProps(IGameObject obj) { var toDraw = new DebugObject(obj); toDraw.Position = new Vector2(0,0); SpriteBatch.Draw( texture: TextureLoader.TheOnePixel, destinationRectangle: new Rectangle((int)toDraw.Position.X, (int)toDraw.Position.Y, (int)TextureLoader.Font.MeasureString(toDraw.ToString()).X, (int)TextureLoader.Font.MeasureString(toDraw.ToString()).Y), color: Color.Black * 0.4f); SpriteBatch.DrawString(TextureLoader.Font, toDraw.ToString(), toDraw.Position, Color.White); }
/// <summary> /// /// </summary> /// <param name="item"></param> private void Anchor(DebugObject item) { bool contains = this.AnchoredObjects.Any(p => p.Id == item.Id); if (!contains) { item.Position = new Vector2(this.indent, 0); this.AnchoredObjects.AddLast(new LinkedListNode<DebugObject>(item)); this.indent += (int)TextureLoader.Font.MeasureString(item.LongestLine).X; } else { var toRemove = this.AnchoredObjects.First(e => e.Id == item.Id); this.indent -= (int)TextureLoader.Font.MeasureString(item.LongestLine).X; for (var i = AnchoredObjects.Last.Value; i != AnchoredObjects.Find(toRemove).Value; i = AnchoredObjects.Find(i).Previous.Value) { i.Position = AnchoredObjects.Find(i).Previous.Value.Position; } this.AnchoredObjects.Remove(toRemove); } }