private void FinishSegment(string currentSegment, ref Vector2 position, Color color, string reference) { if (currentSegment.Length == 0) { return; } Vector2 size = font.MeasureString(currentSegment); Vector2 pos = new Vector2(position.X, position.Y); this.text.Add(new TextSegment(currentSegment, color, pos, size, reference)); position.X += size.X; MaxWidth = Math.Max(position.X, MaxWidth); }
private void DrawEntities(RenderInfo info, EntityLayer entities) { int tiles = layers[currentLayer].Type == LayerType.Entities ? 0: 1; Vector2 topLeft = new Vector2(0, 0); if (Editing.Camera != null) { topLeft = new Vector2(info.Camera.Left, info.Camera.Top); } for (int i = 0; i < entities.Components.Count; i++) { Entity entity = entities.Components[i] as Entity; if (entity != null && entity.Shape != null && entity.Properties.GetInt("isTile", 0) == tiles) { info.Canvas.StrokeColor = Color.White; info.Canvas.LineWidth = 4; topLeft = DrawEntity(info, topLeft, entity); info.Canvas.StrokeColor = Color.Black; if (entity == selectedEntity) { info.Canvas.StrokeColor = Color.Yellow; } else if (entity == hoveringEntity) { info.Canvas.StrokeColor = Color.Cyan; } info.Canvas.LineWidth = 2; topLeft = DrawEntity(info, topLeft, entity); if (info.IsTopState) { if (entity == selectedEntity) { string name = selectedEntity.Properties.GetString(EntityFactory.PROPERTY_NAME_BLUEPRINT, entity.GetType().Name); Vector2 size = font.MeasureString(name); font.DrawString(info, name, entity.Position - topLeft - size * 0.5f, Color.Yellow); } else if (entity == hoveringEntity) { string name = hoveringEntity.Properties.GetString(EntityFactory.PROPERTY_NAME_BLUEPRINT, hoveringEntity.GetType().Name); Vector2 size = font.MeasureString(name); font.DrawString(info, name, entity.Position - topLeft - size * 0.5f, Color.Cyan); } } } } if (info.IsTopState) { info.Canvas.StrokeColor = Color.Red; info.Canvas.LineWidth = 2; if (drawingEntity != null && hoveringEntity == null) { DrawEntity(info, topLeft, drawingEntity); string name = drawingEntity.Properties.GetString(EntityFactory.PROPERTY_NAME_BLUEPRINT, drawingEntity.GetType().Name);; Vector2 size = font.MeasureString(name); font.DrawString(info, name, drawingEntity.Position - topLeft - size * 0.5f, Color.Red); } else if (layers[currentLayer].Type == LayerType.Tiles) { Vector2 pos = SnapPosition(mousePosition) - topLeft; info.Canvas.Begin(); info.Canvas.MoveTo(pos - Vector2.One * layers[currentLayer].TileSize * 0.5f); info.Canvas.LineTo(pos + Vector2.One * layers[currentLayer].TileSize * 0.5f); info.Canvas.MoveTo(pos + new Vector2(layers[currentLayer].TileSize * 0.5f, -layers[currentLayer].TileSize * 0.5f)); info.Canvas.LineTo(pos + new Vector2(-layers[currentLayer].TileSize * 0.5f, layers[currentLayer].TileSize * 0.5f)); info.Canvas.Stroke(); } } }