Advertisement
s4000

DAV_LegendGemCountPlugin

May 28th, 2020 (edited)
557
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.10 KB | None | 0 0
  1. using System;
  2. using System.Drawing;
  3. using System.Collections.Generic;
  4. using Turbo.Plugins.Default;
  5.  
  6. namespace Turbo.Plugins.DAV
  7. {
  8.     public class DAV_LegendGemCountPlugin : BasePlugin, IInGameTopPainter {
  9.         public bool alwayShow { get; set; } = false;
  10.         public float offsetRatioX { get; set; }
  11.         public float offsetRatioY { get; set; }
  12.         public float GemSize { get; set; }
  13.         public Func<int, string> GemTotal { get; set; }
  14.         public IFont GemQtyFont { get; set; }
  15.         public ITexture GemInvTexture { get; set; }
  16.  
  17.         private ITexture[] GemLvlTexture { get; set; } = new ITexture[8];
  18.         private int[] GemLvlQty { get; set; } = new int[8];
  19.         private List<uint> GemSno { get; set; } = new List<uint> {
  20.             3248511367, 3249948847, 3248547304, 3250847272, 3249661351,
  21.             3248583241, 3248655115, 3248762926, 3248798863, 3248726989,
  22.             3249912910, 3249697288, 3248691052, 3250919146, 3249769162,
  23.             3249841036, 3248619178, 3249733225
  24.         };
  25.  
  26.         public DAV_LegendGemCountPlugin() {
  27.             Enabled = true;
  28.         }
  29.  
  30.         public override void Load(IController hud) {
  31.             base.Load(hud);
  32.  
  33.             offsetRatioX = -0.25f;
  34.             offsetRatioY = 0.1f;
  35.             GemSize = 30f;
  36.             GemTotal = (qty) => "Total : " + qty.ToString();
  37.             GemQtyFont = Hud.Render.CreateFont("Arial", 10, 255, 255, 255, 255, true, false, 128, 0, 0, 0, true);
  38.             GemInvTexture = Hud.Texture.GetTexture(2523381246);
  39.  
  40.             GemLvlTexture[0] = Hud.Texture.GetTexture(469991964);
  41.             GemLvlTexture[1] = Hud.Texture.GetTexture(469991931);
  42.             GemLvlTexture[2] = Hud.Texture.GetTexture(469991898);
  43.             GemLvlTexture[3] = Hud.Texture.GetTexture(469991865);
  44.             GemLvlTexture[4] = Hud.Texture.GetTexture(469991832);
  45.             GemLvlTexture[5] = Hud.Texture.GetTexture(469991799);
  46.             GemLvlTexture[6] = Hud.Texture.GetTexture(795145451);
  47.             GemLvlTexture[7] = Hud.Texture.GetTexture(795145286);
  48.         }
  49.  
  50.         public void PaintTopInGame(ClipState clipState) {
  51.             if (clipState != ClipState.Inventory) return;
  52.  
  53.             var uiInvRect = Hud.Inventory.InventoryMainUiElement.Rectangle;
  54.             var GemInvRect = new RectangleF(uiInvRect.Left + (uiInvRect.Width - GemInvTexture.Width) * 0.5f, uiInvRect.Top + uiInvRect.Height * 0.04f, GemInvTexture.Width, GemInvTexture.Height);
  55.             GemInvTexture.Draw(GemInvRect.X, GemInvRect.Y, GemInvRect.Width, GemInvRect.Height);
  56.  
  57.             if (alwayShow || Hud.Window.CursorInsideRect(GemInvRect.X, GemInvRect.Y, GemInvRect.Width, GemInvRect.Height)) {
  58.                 for (var i = 0; i < 8; i++)
  59.                     GemLvlQty[i] = 0;
  60.  
  61.                 foreach (var item in Hud.Inventory.ItemsInStash)
  62.                     CountGems(item);
  63.  
  64.                 foreach (var item in Hud.Inventory.ItemsInInventory)
  65.                     CountGems(item);
  66.  
  67.                 var xref = uiInvRect.Left + uiInvRect.Width * offsetRatioX;
  68.                 var yref = uiInvRect.Top + uiInvRect.Height * offsetRatioY;
  69.                 var h = (GemSize - GemQtyFont.GetTextLayout("100").Metrics.Height) / 2;
  70.                 var tQty = 0;
  71.                 for (var i = 0; i < 8; i++) {
  72.                     GemLvlTexture[i].Draw(xref, yref, GemSize, GemSize);
  73.                     tQty += GemLvlQty[i];
  74.                     GemQtyFont.DrawText(GemLvlQty[i].ToString(), xref + GemSize, yref + h);
  75.                     yref += GemSize;
  76.                 }
  77.  
  78.                 GemQtyFont.DrawText(GemTotal(tQty), xref, yref + h);
  79.             }
  80.         }
  81.  
  82.         private void CountGems(IItem item) {
  83.             if (GemSno.Contains(item.SnoItem.Sno)) {
  84.                 var gemLvl = item.JewelRank;
  85.                 if (gemLvl == 150) GemLvlQty[0]++;
  86.                 else if (gemLvl >= 140) GemLvlQty[1]++;
  87.                 else if (gemLvl >= 130) GemLvlQty[2]++;
  88.                 else if (gemLvl >= 120) GemLvlQty[3]++;
  89.                 else if (gemLvl >= 110) GemLvlQty[4]++;
  90.                 else if (gemLvl >= 100) GemLvlQty[5]++;
  91.                 else if (gemLvl >= 50) GemLvlQty[6]++;
  92.                 else GemLvlQty[7]++;
  93.             }
  94.             else if (item.SocketCount > 0 && item.ItemsInSocket != null) {
  95.                 var socketedItem = item.ItemsInSocket[0];
  96.                 if (GemSno.Contains(socketedItem.SnoItem.Sno)) {
  97.                     var gemLvl = socketedItem.JewelRank;
  98.                     if (gemLvl == 150) GemLvlQty[0]++;
  99.                     else if (gemLvl >= 140) GemLvlQty[1]++;
  100.                     else if (gemLvl >= 130) GemLvlQty[2]++;
  101.                     else if (gemLvl >= 120) GemLvlQty[3]++;
  102.                     else if (gemLvl >= 110) GemLvlQty[4]++;
  103.                     else if (gemLvl >= 100) GemLvlQty[5]++;
  104.                     else if (gemLvl >= 50) GemLvlQty[6]++;
  105.                     else GemLvlQty[7]++;
  106.                 }
  107.             }
  108.         }
  109.     }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement