Advertisement
zjqyf

GLQ_ArmorySetInfo.cs

Mar 19th, 2019
874
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.53 KB | None | 0 0
  1. using Turbo.Plugins.Default;
  2. using System.Linq;
  3. namespace Turbo.Plugins.glq
  4. {
  5. public class GLQ_ArmorySetInfo : BasePlugin, IInGameTopPainter
  6. {
  7. public TopLabelDecorator InArmorySetList { get; set; }
  8. private int stashPage, stashTab, stashTabAbs;
  9. private IWatch _watch;
  10. public GLQ_ArmorySetInfo()
  11. {
  12. Enabled = true;
  13. }
  14. public override void Load(IController hud)
  15. {
  16. base.Load(hud);
  17. InArmorySetList = new TopLabelDecorator(Hud)
  18. {
  19. BackgroundBrush = Hud.Render.CreateBrush(100, 0, 0, 0, 0),
  20. BorderBrush = Hud.Render.CreateBrush(255, 0, 0, 0, -1),
  21. TextFont = Hud.Render.CreateFont("tahoma", 8, 255, 255, 255, 255, false, false, true),
  22. };
  23. _watch = Hud.Time.CreateAndStartWatch();
  24. }
  25. public void PaintTopInGame(ClipState clipState)
  26. {
  27. var uiInv = Hud.Inventory.InventoryMainUiElement;
  28. if (!uiInv.Visible) return;
  29. var HoveredItem = Hud.Inventory.HoveredItem;
  30. if (HoveredItem != null)
  31. {
  32. var player = Hud.Game.Me;
  33. string text = null;
  34. for (int i = 0; i < player.ArmorySets.Length; ++i)
  35. {
  36. var armorySet = player.ArmorySets[i];
  37. if (armorySet != null)
  38. {
  39. if (armorySet.ContainsItem(HoveredItem))
  40. {
  41. var name = Hud.Game.Me.ArmorySets[armorySet.Index].Name;
  42. text = text + name + "\n";
  43. }
  44. }
  45. }
  46. if (text != null)
  47. {
  48. var fulltext = "\n" + "ArmorySets:" + "\n" + "\n" + text;
  49. InArmorySetList.TextFunc = () => fulltext;
  50. var uiMain = Hud.Inventory.GetHoveredItemMainUiElement();
  51. var layout = InArmorySetList.TextFont.GetTextLayout(fulltext);
  52. InArmorySetList.Paint(uiMain.Rectangle.Right, uiMain.Rectangle.Top, layout.Metrics.Width + Hud.Window.Size.Width * 0.01f , layout.Metrics.Height, HorizontalAlign.Center);
  53. }
  54. }
  55. var allitem = Hud.Game.Items.Where(x => x.Location != ItemLocation.Merchant && x.Location != ItemLocation.Floor);
  56. stashTab = Hud.Inventory.SelectedStashTabIndex;
  57. stashPage = Hud.Inventory.SelectedStashPageIndex;
  58. stashTabAbs = stashTab + stashPage * Hud.Inventory.MaxStashTabCountPerPage;
  59. if (clipState != ClipState.Inventory) return;
  60. foreach (var item in allitem)
  61. {
  62. if (item.Location == ItemLocation.Stash)
  63. {
  64. var tabIndex = item.InventoryY / 10;
  65. if (tabIndex != stashTabAbs) continue;
  66. }
  67. if ((item.InventoryX < 0) || (item.InventoryY < 0)) continue;
  68.  
  69. var rect = Hud.Inventory.GetItemRect(item);
  70. if (rect == System.Drawing.RectangleF.Empty) continue;
  71. DrawArmorySet(item, rect);
  72. }
  73. }
  74. private void DrawArmorySet(IItem item, System.Drawing.RectangleF rect)
  75. {
  76.  
  77. bool InArmorySet = false;
  78. if ((item.Location != ItemLocation.Inventory) && (item.Location != ItemLocation.Stash)) return;
  79.  
  80. for (int i = 0; i < Hud.Game.Me.ArmorySets.Length; ++i)
  81. {
  82. var armorySet = Hud.Game.Me.ArmorySets[i];
  83. if (armorySet != null)
  84. {
  85. if (armorySet.ContainsItem(item))
  86. {
  87. InArmorySet = true;
  88. break;
  89. }
  90. }
  91. }
  92. if (InArmorySet)
  93. {
  94. var ArmorySetTexture = Hud.Texture.GetTexture(670858621);
  95. var h = ArmorySetTexture.Height * 0.4f / 1200.0f * Hud.Window.Size.Height;
  96. var rh = h;
  97. var mod = (_watch.ElapsedMilliseconds) % 1000;
  98. var ratio = 0.8f + 1.2f / 1000.0f * (mod < 500 ? mod : 1000 - mod);
  99. rh *= ratio;
  100. var x = rect.Right - h * 1.4f - ((rh - h) / 2);
  101. var y = rect.Top - h * 0.20f - ((rh - h) / 2);
  102. ArmorySetTexture.Draw(x, y, rh, rh, 1);
  103. }
  104. }
  105. }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement