Advertisement
RuneB

BuffLabelsPlugin.cs

Feb 19th, 2017
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.84 KB | None | 0 0
  1. namespace Turbo.Plugins.RuneB
  2. {
  3.     using Turbo.Plugins.Default;
  4.  
  5.     public class BuffLabelsPlugin : BasePlugin, IInGameWorldPainter
  6.     {
  7.         public bool IgnorePain { get; set; }
  8.         public bool Oculus { get; set; }
  9.         public bool InnerSanctuary { get; set; }
  10.         public bool FlyingDragon { get; set; }
  11.  
  12.         public float YPos { get; set; }
  13.         public float XPos { get; set; }
  14.  
  15.         public float YPosIncrement { get; set; }
  16.  
  17.         public float LabelWidthPercentage { get; set; }
  18.         public float LabelHeightPercentage { get; set; }
  19.  
  20.         public bool Debug { get; set; }
  21.  
  22.         public IFont TextFont { get; set; }
  23.         public IBrush BorderBrush { get; set; }
  24.         public IBrush BackgroundBrushIP { get; set; }
  25.         public IBrush BackgroundBrushOC { get; set; }
  26.         public IBrush BackgroundBrushIS { get; set; }
  27.         public IBrush BackgroundBrushFD { get; set; }
  28.  
  29.         private float LW, LH, Width, Height, YPosTemp;
  30.  
  31.         public BuffLabelsPlugin()
  32.         {
  33.             Enabled = true;
  34.         }
  35.  
  36.         public override void Load(IController hud)
  37.         {
  38.             base.Load(hud);
  39.  
  40.             //Turn labels on and off
  41.             IgnorePain = true;
  42.             Oculus = true;
  43.             InnerSanctuary = true;
  44.             FlyingDragon = true;
  45.            
  46.             //Horizontal and Vertical label positions.
  47.             YPos = 0.65f;
  48.             XPos = 0.5f;
  49.  
  50.             //Label size is based on a percentage of screen width/height
  51.             LabelWidthPercentage = 0.052f;
  52.             LabelHeightPercentage = 0.016f;
  53.            
  54.             //Vertical distance between labels
  55.             YPosIncrement = 0.02f;
  56.  
  57.             //If true labels are always shown
  58.             Debug = false;
  59.  
  60.             TextFont = Hud.Render.CreateFont("tahoma", 6, 240, 240, 240, 240, true, false, true);
  61.             BorderBrush = Hud.Render.CreateBrush(150, 30, 30, 30, 0);
  62.  
  63.             BackgroundBrushIP = Hud.Render.CreateBrush(100, 100, 225, 100, 0);   // Ignore Pain
  64.             BackgroundBrushOC = Hud.Render.CreateBrush(100, 255, 255, 50, 0);    // Oculus
  65.             BackgroundBrushIS = Hud.Render.CreateBrush(100, 185, 220, 245, 0);   // Inner Sanctuary
  66.             BackgroundBrushFD = Hud.Render.CreateBrush(100, 50, 200, 255, 0);    // Flying Dragon
  67.  
  68.             Width = Hud.Window.Size.Width;
  69.             Height = Hud.Window.Size.Height;
  70.             LW = Width * LabelWidthPercentage;     // label width
  71.             LH = Height * LabelHeightPercentage;   // label height
  72.  
  73.             YPosTemp = YPos;          
  74.         }
  75.  
  76.         public void PaintWorld(WorldLayer layer)
  77.         {
  78.             if (IgnorePain && (Hud.Game.Me.Powers.BuffIsActive(79528, 0) || Hud.Game.Me.Powers.BuffIsActive(79528, 1)) || Debug)
  79.                 DrawLabel(BackgroundBrushIP,"Ignore Pain");
  80.  
  81.             if (Oculus && Hud.Game.Me.Powers.BuffIsActive(402461, 2) || Debug)
  82.                 DrawLabel(BackgroundBrushOC, "Oculus");
  83.  
  84.             if (InnerSanctuary && Hud.Game.Me.Powers.BuffIsActive(317076, 1) || Debug)
  85.                 DrawLabel(BackgroundBrushIS, "Inner Sanctuary");
  86.  
  87.             if (FlyingDragon && Hud.Game.Me.Powers.BuffIsActive(246562, 1) || Debug)
  88.                 DrawLabel(BackgroundBrushFD, "Flying Dragon");
  89.  
  90.             YPosTemp = YPos;
  91.         }
  92.  
  93.  
  94.  
  95.         private void DrawLabel(IBrush label, string buffText) {
  96.             YPosTemp += YPosIncrement;
  97.             BorderBrush.DrawRectangle(Width * XPos - LW * 1.05f * .5f, Height * YPosTemp - LH * 1.1f, LW * 1.05f, LH * 1.2f);
  98.             label.DrawRectangle(Width * XPos - LW * .5f, Height * YPosTemp - LH, LW, LH);
  99.  
  100.             var layout = TextFont.GetTextLayout(buffText);
  101.             TextFont.DrawText(layout, Width * XPos - (layout.Metrics.Width*0.5f), Height * YPosTemp - LH + 2f);
  102.         }
  103.     }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement