Advertisement
Guest User

LegendaryCountPlugin.cs

a guest
Apr 7th, 2017
891
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.58 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 - April 7th 2017
  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.             var uiRect = Hud.Render.GetUiElement("Root.NormalLayer.minimap_dialog_backgroundScreen.minimap_dialog_pve.BoostWrapper.BoostsDifficultyStackPanel.clock").Rectangle;
  49.  
  50.             if (!ShowPercent)
  51.             {
  52.                 var text = string.Format("Legos: {0} / {1} / {2}", LegendaryCount, AncientCount, PrimalCount);
  53.                 var layout = TextFont.GetTextLayout(text);
  54.                 TextFont.DrawText(layout, uiMinimap.Left, uiRect.Top + uiRect.Height * 1.15f);
  55.             }
  56.             else
  57.             {
  58.                 var text = string.Format("Legos: {0} / {1} ({2:0.#}%) / {3} ({4:0.##}%)", LegendaryCount, AncientCount, (AncientCount > 0 ? ((float)AncientCount * 100 / LegendaryCount) : 0f), PrimalCount, (PrimalCount > 0 ? ((float)PrimalCount * 100 / LegendaryCount) : 0f));
  59.                 var layout = TextFont.GetTextLayout(text);
  60.                 TextFont.DrawText(layout, uiMinimap.Left, uiRect.Top + uiRect.Height * 1.15f);
  61.             }
  62.         }
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement