Advertisement
zjqyf

GLQ_GRProgressionToTime.cs

Aug 5th, 2017
1,946
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. using Turbo.Plugins.Default;
  2.  
  3. namespace Turbo.Plugins.glq
  4. {
  5. public class GLQ_GRProgressionToTime : BasePlugin, IInGameTopPainter
  6. {
  7. public IFont BonusTimeFont { get; set; }
  8. public IFont MalusTimeFont { get; set; }
  9.  
  10. private IFont currentFont;
  11.  
  12. public GLQ_GRProgressionToTime()
  13. {
  14. Enabled = true;
  15. }
  16.  
  17. public override void Load(IController hud)
  18. {
  19. base.Load(hud);
  20. MalusTimeFont = Hud.Render.CreateFont("tahoma", 7, 255, 250, 100, 100, true, false, 160, 0, 0, 0, true);
  21. BonusTimeFont = Hud.Render.CreateFont("tahoma", 7, 255, 128, 255, 0, true, false, 160, 0, 0, 0, true);
  22. }
  23.  
  24. public void PaintTopInGame(ClipState clipState)
  25. {
  26. if (Hud.Game.SpecialArea != SpecialArea.GreaterRift) return;
  27. if (clipState != ClipState.BeforeClip) return;
  28.  
  29. var ui = Hud.Render.GreaterRiftBarUiElement;
  30. if (!ui.Visible) return;
  31.  
  32. var secondsLeft = (Hud.Game.CurrentTimedEventEndTick - (double)Hud.Game.CurrentGameTick) / 60.0d;
  33. var percent = Hud.Game.RiftPercentage;
  34.  
  35. if (!(secondsLeft > 0)) return;
  36.  
  37. string text;
  38. var _x = 9000000000 / ui.Rectangle.Width;
  39. var currentX = ui.Rectangle.Left + ui.Rectangle.Width / 100.0f * percent;
  40. var timeX = ui.Rectangle.Right - (float)(ui.Rectangle.Width / 900.0f * secondsLeft);
  41. var _time = (currentX - timeX) * _x;
  42. if (_time <= 0)
  43. {
  44. text = "- " + ValueToString((long)_time, ValueFormat.LongTime);
  45. currentFont = MalusTimeFont;
  46. }
  47. else
  48. {
  49. text = "+ " + ValueToString((long)_time, ValueFormat.LongTime);
  50. currentFont = BonusTimeFont;
  51. }
  52.  
  53. var textLayout = currentFont.GetTextLayout(text);
  54. var x = (float)currentX - textLayout.Metrics.Width / 2;
  55. var y = ui.Rectangle.Top - ui.Rectangle.Height * 0.1f - textLayout.Metrics.Height;
  56. currentFont.DrawText(textLayout, x, y);
  57. }
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement