Advertisement
jarppaaja

UpgradeRareRecipe rev 913

Jan 31st, 2019
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.20 KB | None | 0 0
  1. // UpgradeRareRecipe.cs "$Revision: 913 $" "$Date: 2019-01-31 12:48:52 +0200 (to, 31 tammi 2019) $"
  2. using System.Linq;
  3. using Turbo.Plugins;
  4. using Turbo.Plugins.Default;
  5.  
  6. namespace Turbo.plugins.JarJar.DefaultUI
  7. {
  8.     class UpgradeRareRecipe : BasePlugin, ICustomizer, IInGameWorldPainter, IInGameTopPainter
  9.     {
  10.         public bool ShowInventorynfo { get; set; } = true;
  11.         public bool ShowItemInfo { get; set; } = true;
  12.  
  13.         public string[] ItemTypes { get; set; } // = item.SnoItem.SnoItemType.Code
  14.  
  15.         public IFont ItemTypeFont { get; set; }
  16.         public IBrush InventoryBorderBrush { get; set; }
  17.         public WorldDecoratorCollection RareKeepDecorator { get; set; }
  18.  
  19.         public UpgradeRareRecipe() { Enabled = true; }
  20.  
  21.         public void Customize()
  22.         {
  23.             // Disable original HoveredItemInfoPlugin.
  24.             Hud.TogglePlugin<Turbo.Plugins.Default.HoveredItemInfoPlugin>(false);
  25.         }
  26.  
  27.         public override void Load(IController hud)
  28.         {
  29.             base.Load(hud);
  30.  
  31.             ItemTypeFont = Hud.Render.CreateFont("tahoma", 7, 255, 154, 105, 24, true, false, 128, 0, 0, 0, true);
  32.  
  33.             InventoryBorderBrush = Hud.Render.CreateBrush(200, 255, 255, 102, -1.6f);   // quite light yellow
  34.  
  35.             RareKeepDecorator = new WorldDecoratorCollection(
  36.                 new GroundCircleDecorator(Hud)
  37.                 {
  38.                     Brush = Hud.Render.CreateBrush(192, 255, 255, 0, -2),
  39.                     Radius = 1.25f,
  40.                     RadiusTransformator = new StandardPingRadiusTransformator(Hud, 333),
  41.                 },
  42.                 new MapShapeDecorator(Hud)
  43.                 {
  44.                     ShapePainter = new CircleShapePainter(Hud),
  45.                     Brush = Hud.Render.CreateBrush(255, 255, 255, 0, 0),
  46.                     ShadowBrush = Hud.Render.CreateBrush(96, 0, 0, 0, 1),
  47.                     Radius = 6,
  48.                     RadiusTransformator = new StandardPingRadiusTransformator(Hud, 333),
  49.                 });
  50.         }
  51.  
  52.         public void PaintWorld(WorldLayer layer)
  53.         {
  54.             if (ItemTypes.Length == 0) return;
  55.             var items = Hud.Game.Items.Where(item => item.Location == ItemLocation.Floor);
  56.             foreach (var item in items)
  57.             {
  58.                 if (item.IsRare && isRecipeItem(item))
  59.                 {
  60.                     RareKeepDecorator.Paint(layer, item, item.FloorCoordinate, null);
  61.                 }
  62.             }
  63.         }
  64.  
  65.         public void PaintTopInGame(ClipState clipState)
  66.         {
  67.             if (ShowItemInfo && clipState == ClipState.AfterClip)
  68.             {
  69.                 paintHoveredItem();
  70.                 return;
  71.             }
  72.             if (ShowItemInfo && clipState == ClipState.Inventory)
  73.             {
  74.                 paintInventory();
  75.                 return;
  76.             }
  77.         }
  78.  
  79.         void paintHoveredItem()
  80.         {
  81.             var item = Hud.Inventory.HoveredItem;
  82.             if (item == null || item.Unidentified) return;
  83.  
  84.             var uicMain = Hud.Inventory.GetHoveredItemMainUiElement();
  85.             var uicTop = Hud.Inventory.GetHoveredItemTopUiElement();
  86.  
  87.             var iLevelText = item.SnoItem.SnoItemType.Code;
  88.             var iLevelLayout = ItemTypeFont.GetTextLayout(iLevelText);
  89.             ItemTypeFont.DrawText(iLevelLayout, uicTop.Rectangle.Left - Hud.Window.Size.Height * 0.0166f, uicTop.Rectangle.Top + (Hud.Window.Size.Height * 0.022f - iLevelLayout.Metrics.Height) / 2);
  90.         }
  91.  
  92.         void paintInventory()
  93.         {
  94.             var uiInv = Hud.Inventory.InventoryMainUiElement;
  95.             if (!uiInv.Visible) return;
  96.  
  97.             var items = Hud.Game.Items.Where(item => item.IsRare && item.Location == ItemLocation.Inventory);
  98.             foreach (var item in items)
  99.             {
  100.                 var rect = Hud.Inventory.GetItemRect(item);
  101.                 if (rect == System.Drawing.RectangleF.Empty) continue;
  102.                 InventoryBorderBrush.DrawRectangle(rect.X, rect.Y, rect.Width, rect.Height);
  103.             }
  104.         }
  105.  
  106.         bool isRecipeItem(IItem item)
  107.         {
  108.             return ItemTypes.Any(x => x == item.SnoItem.SnoItemType.Code);
  109.         }
  110.     }
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement