Advertisement
Guest User

DisplayCraftingMaterialPlugin.cs v2.0

a guest
Apr 12th, 2017
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.19 KB | None | 0 0
  1. using System.Globalization;
  2.  
  3. namespace Turbo.Plugins.DM
  4. {
  5.     using System.Linq;
  6.     using Turbo.Plugins.Default;
  7.    
  8.     public class DisplayCraftingMaterialPlugin : BasePlugin, IInGameTopPainter
  9.     {
  10.  
  11.         public TopLabelDecorator YellowDecorator { get; set; }
  12.         public TopLabelDecorator TealDecorator { get; set; }
  13.         public TopLabelDecorator BlueDecorator { get; set; }
  14.         public TopLabelDecorator WhiteDecorator { get; set; }
  15.         public TopLabelDecorator OrangeDecorator { get; set; }
  16.        
  17.         public string PickItem { get; set; }
  18.         public bool Cycle {get; set;}
  19.         public float DisplayTime {get; set;}
  20.        
  21.         private bool _timerRunning = false;
  22.         private float _tick;
  23.        
  24.         public DisplayCraftingMaterialPlugin()
  25.         {
  26.             Enabled = true;
  27.         }
  28.  
  29.         public override void Load(IController hud)
  30.         {
  31.             base.Load(hud);
  32.            
  33.             PickItem = "DeathsBreath";
  34.             Cycle = false;
  35.             DisplayTime = 20f;
  36.            
  37.             YellowDecorator = new TopLabelDecorator(Hud)
  38.             {
  39.                 TextFont = Hud.Render.CreateFont("tahoma", 7, 255, 200, 205, 50, false, false, false),
  40.                 BackgroundTexture1 = Hud.Texture.ButtonTextureGray,
  41.                 BackgroundTexture2 = Hud.Texture.BackgroundTextureOrange,
  42.                 BackgroundTextureOpacity1 = 1.0f,
  43.                 BackgroundTextureOpacity2 = 1.0f,
  44.                 TextFunc = () => Hud.Game.Me.Materials.VeiledCrystal.ToString("D", CultureInfo.InvariantCulture),
  45.                 HintFunc = () => "Amount of Veiled Crystals",
  46.             };
  47.            
  48.             TealDecorator = new TopLabelDecorator(Hud)
  49.             {
  50.                 TextFont = Hud.Render.CreateFont("tahoma", 7, 255, 50, 200, 205, false, false, false),
  51.                 BackgroundTexture1 = Hud.Texture.ButtonTextureGray,
  52.                 BackgroundTexture2 = Hud.Texture.BackgroundTextureOrange,
  53.                 BackgroundTextureOpacity1 = 1.0f,
  54.                 BackgroundTextureOpacity2 = 1.0f,
  55.                 TextFunc = () => Hud.Game.Me.Materials.DeathsBreath.ToString("D", CultureInfo.InvariantCulture),
  56.                 HintFunc = () => "Amount of Death's Breaths",
  57.             };
  58.            
  59.             BlueDecorator = new TopLabelDecorator(Hud)
  60.             {
  61.                 TextFont = Hud.Render.CreateFont("tahoma", 7, 255, 50, 122, 205, false, false, false),
  62.                 BackgroundTexture1 = Hud.Texture.ButtonTextureGray,
  63.                 BackgroundTexture2 = Hud.Texture.BackgroundTextureOrange,
  64.                 BackgroundTextureOpacity1 = 1.0f,
  65.                 BackgroundTextureOpacity2 = 1.0f,
  66.                 TextFunc = () => Hud.Game.Me.Materials.ArcaneDust.ToString("D", CultureInfo.InvariantCulture),
  67.                 HintFunc = () => "Amount of Acrane Dusts",
  68.             };
  69.            
  70.             WhiteDecorator = new TopLabelDecorator(Hud)
  71.             {
  72.                 TextFont = Hud.Render.CreateFont("tahoma", 7, 255, 255, 255, 255, false, false, false),
  73.                 BackgroundTexture1 = Hud.Texture.ButtonTextureGray,
  74.                 BackgroundTexture2 = Hud.Texture.BackgroundTextureOrange,
  75.                 BackgroundTextureOpacity1 = 1.0f,
  76.                 BackgroundTextureOpacity2 = 1.0f,
  77.                 TextFunc = () => Hud.Game.Me.Materials.ReusableParts.ToString("D", CultureInfo.InvariantCulture),
  78.                 HintFunc = () => "Amount of Reusable Parts",
  79.             };
  80.            
  81.             OrangeDecorator = new TopLabelDecorator(Hud)
  82.             {
  83.                 TextFont = Hud.Render.CreateFont("tahoma", 7, 255, 205, 133, 50, false, false, false),
  84.                 BackgroundTexture1 = Hud.Texture.ButtonTextureGray,
  85.                 BackgroundTexture2 = Hud.Texture.BackgroundTextureOrange,
  86.                 BackgroundTextureOpacity1 = 1.0f,
  87.                 BackgroundTextureOpacity2 = 1.0f,
  88.                 TextFunc = () => Hud.Game.Me.Materials.ForgottenSoul.ToString("D", CultureInfo.InvariantCulture),
  89.                 HintFunc = () => "Amount of Forgotten Souls",
  90.             };
  91.  
  92.         }
  93.  
  94.         public void PaintTopInGame(ClipState clipState)
  95.         {
  96.             if (Hud.Render.UiHidden) return;
  97.             if (clipState != ClipState.BeforeClip) return;
  98.            
  99.             var uiRect = Hud.Render.GetUiElement("Root.NormalLayer.game_dialog_backgroundScreenPC.game_window_hud_overlay").Rectangle;
  100.            
  101.             if (Hud.Game.IsInGame && Cycle)
  102.             {
  103.             if (!_timerRunning)
  104.                     _tick = Hud.Game.CurrentGameTick;
  105.                 _timerRunning = true;
  106.                
  107.                 var r = (DisplayTime * 5) - ((Hud.Game.CurrentGameTick - _tick) / 60.0d);
  108.                 if (r >= (DisplayTime * 4))
  109.                 {
  110.                     WhiteDecorator.Paint(uiRect.Left + uiRect.Width * 0.607f, uiRect.Top + uiRect.Height * 0.88f, uiRect.Width * 0.038f, uiRect.Height * 0.12f, HorizontalAlign.Center);
  111.                 }
  112.                 else if (r >= (DisplayTime * 3) && r < (DisplayTime * 4))
  113.                 {
  114.                     BlueDecorator.Paint(uiRect.Left + uiRect.Width * 0.607f, uiRect.Top + uiRect.Height * 0.88f, uiRect.Width * 0.038f, uiRect.Height * 0.12f, HorizontalAlign.Center);
  115.                 }
  116.                 else if (r >= (DisplayTime * 2) && r < (DisplayTime * 3))
  117.                 {
  118.                     YellowDecorator.Paint(uiRect.Left + uiRect.Width * 0.607f, uiRect.Top + uiRect.Height * 0.88f, uiRect.Width * 0.038f, uiRect.Height * 0.12f, HorizontalAlign.Center);
  119.                 }
  120.                 else if (r >= DisplayTime && r < (DisplayTime * 2))
  121.                 {
  122.                     TealDecorator.Paint(uiRect.Left + uiRect.Width * 0.607f, uiRect.Top + uiRect.Height * 0.88f, uiRect.Width * 0.038f, uiRect.Height * 0.12f, HorizontalAlign.Center);
  123.                 }
  124.                 else if (r >= 0 && r < DisplayTime)
  125.                 {
  126.                     OrangeDecorator.Paint(uiRect.Left + uiRect.Width * 0.607f, uiRect.Top + uiRect.Height * 0.88f, uiRect.Width * 0.038f, uiRect.Height * 0.12f, HorizontalAlign.Center);
  127.                 }
  128.                 else
  129.                 {
  130.                     _timerRunning = false;
  131.                 }
  132.                
  133.             }
  134.             else {
  135.             var decorator = DecoratorSelect(PickItem);
  136.            
  137.             decorator.Paint(uiRect.Left + uiRect.Width * 0.607f, uiRect.Top + uiRect.Height * 0.88f, uiRect.Width * 0.038f, uiRect.Height * 0.12f, HorizontalAlign.Center);
  138.             }
  139.         }      
  140.        
  141.         public TopLabelDecorator DecoratorSelect(string Item)
  142.         {
  143.             switch (Item) {
  144.                 case "ReusableParts":
  145.                     return WhiteDecorator;
  146.                 case "ArcaneDust":
  147.                     return BlueDecorator;
  148.                 case "VeiledCrystal":
  149.                     return YellowDecorator;
  150.                 case "DeathsBreath":
  151.                     return TealDecorator;
  152.                 case "ForgottenSoul":
  153.                     return OrangeDecorator;
  154.                 default:
  155.                     return OrangeDecorator;
  156.             }        
  157.         }
  158.        
  159.     }
  160.  
  161. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement