Advertisement
Guest User

LegendaryCountPlugin.cs

a guest
Apr 7th, 2017
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.29 KB | None | 0 0
  1. using System.Text;
  2. using Turbo.Plugins.Default;
  3.  
  4. namespace Turbo.Plugins.Csavo // Plugin for counting legendary drops. Credits to JackCeparou (http://www.ownedcore.com/forums/members/1164396-jackceparou.html) for helping out!
  5. {
  6.     public class LegendaryCountPlugin : BasePlugin, IInGameTopPainter, ILootGeneratedHandler // version 1.0
  7.     {
  8.         public bool ShowPercent { get; set; }
  9.         public int LegendaryCount { get; private set; }
  10.         public int AncientCount { get; private set; }
  11.         public int PrimalCount { get; private set; }
  12.         public IFont TextFont { get; set; }
  13.  
  14.         public LegendaryCountPlugin()
  15.         {
  16.             Enabled = true;
  17.         }
  18.  
  19.         public override void Load(IController hud)
  20.         {
  21.             base.Load(hud);
  22.  
  23.             ShowPercent = true;
  24.  
  25.             LegendaryCount = 0;
  26.             AncientCount = 0;
  27.             PrimalCount = 0;
  28.  
  29.             TextFont = Hud.Render.CreateFont("tahoma", 7, 255, 255, 235, 170, false, false, true);
  30.         }
  31.  
  32.         public void OnLootGenerated(IItem item, bool gambled)
  33.         {
  34.             if (item.IsLegendary)
  35.             {
  36.                 if (item.AncientRank >= 0) LegendaryCount++;
  37.                 if (item.AncientRank == 1) AncientCount++;
  38.                 if (item.AncientRank == 2) PrimalCount++;
  39.             }
  40.         }
  41.  
  42.         public void PaintTopInGame(ClipState clipState)
  43.         {
  44.             if (clipState != ClipState.BeforeClip) return;
  45.             if (TextFont == null) return;
  46.  
  47.             var uiMinimap = Hud.Render.MinimapUiElement.Rectangle;
  48.  
  49.             if (!ShowPercent)
  50.             {
  51.                 var text = string.Format("Legs: {0} / {1} / {2}", LegendaryCount, AncientCount, PrimalCount);
  52.                 var layout = TextFont.GetTextLayout(text);
  53.                 TextFont.DrawText(layout, uiMinimap.Left, uiMinimap.Top);
  54.             }
  55.             else
  56.             {
  57.                 var text = string.Format("Legs: {0} / {1} ({2:0.#}%) / {3} ({4:0.##}%)", LegendaryCount, AncientCount, ((float)AncientCount * 100 / LegendaryCount), PrimalCount, ((float)PrimalCount * 100 / LegendaryCount));
  58.                 var layout = TextFont.GetTextLayout(text);
  59.                 TextFont.DrawText(layout, uiMinimap.Left, uiMinimap.Top);
  60.             }
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement