ProgressTextureRect.cs 902 B

12345678910111213141516171819202122232425262728
  1. using System.Numerics;
  2. using Content.Client.UserInterface.Systems;
  3. using Robust.Client.Graphics;
  4. using Robust.Client.UserInterface.Controls;
  5. namespace Content.Client.UserInterface.Controls
  6. {
  7. public sealed class ProgressTextureRect : TextureRect
  8. {
  9. public float Progress;
  10. private readonly ProgressColorSystem _progressColor;
  11. public ProgressTextureRect()
  12. {
  13. _progressColor = IoCManager.Resolve<IEntityManager>().System<ProgressColorSystem>();
  14. }
  15. protected override void Draw(DrawingHandleScreen handle)
  16. {
  17. var dims = Texture != null ? GetDrawDimensions(Texture) : UIBox2.FromDimensions(Vector2.Zero, PixelSize);
  18. dims.Top = Math.Max(dims.Bottom - dims.Bottom * Progress,0);
  19. handle.DrawRect(dims, _progressColor.GetProgressColor(Progress));
  20. base.Draw(handle);
  21. }
  22. }
  23. }